ISDATE (date in UK format DB in US format)

  • I am using the function ISDATE against column of type varchar which is a date in UK date format (dd/mm/yyyy) but the Database ‘s collation has the date format (mm/dd/yyyy). This means I have a lot of dates showing as non-dates.

    How can I get ISDATE to work with the UK format on a US database without changing the collation?

    Many Thanks

  • first of all, can you detail why you are storing dates as varchar and not datetime and what is the business requirements for doing this

    secondly you could set dateformat = dmy and then convert the varchar to a db date, then do isdate

    eg

    set dateformat dmy

    select isdate(convert(date,'01/01/2011'))

  • Edward-445599 (12/7/2011)


    I am using the function ISDATE against column of type varchar which is a date in UK date format (dd/mm/yyyy) but the Database ‘s collation has the date format (mm/dd/yyyy). This means I have a lot of dates showing as non-dates.

    How can I get ISDATE to work with the UK format on a US database without changing the collation?

    Many Thanks

    You can use DATEFORMAT to set the date format of your choice for the current execution.

    May be this can help:

    SET DATEFORMAT 'dmy'

    GO

    DECLARE @UKFormatDateTime DATETIME

    SET @UKFormatDateTime = '21/12/2011'

    PRINT @UKFormatDateTime


    Sujeet Singh

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

  • thanks all

  • happy to help.

    as i said in my original post, what is the business requirement for having dates as varchars? if there isnt any, I would recommend putting a task together to store them as datetime and use an ISO standard, that way you dont have regional issues.

  • I am in the process of doing that but I want to make sure all the values are valid dates first

  • excellent, thats good to hear

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply