Help with dates

  • I have a date in british format 31/12/03

    I need to convert it into a default sql datetime format i.e 2003-12-31 00:00:00

    Can anyone help me please. I know it is simple but get stuck with dates every time!

    Thanks

    Karl

  • I do not know your context, but try...

     
    
    Declare @Test DateTime
    SET DATEFORMAT dmy
    Select @Test = '31/12/03'
    Print Convert(VarChar(25), @Test)
    SET DATEFORMAT mdy -- back to US default



    Once you understand the BITs, all the pieces come together

  • This should work:

    CONVERT(datetime, datefield, 120)

    Refer to the BOL, use the INDEX tab and enter CONVERT.

    -SQLBill

  • Thanks

    I will give it a try

Viewing 4 posts - 1 through 3 (of 3 total)

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