Problem converting date in SQL

  • hi all,

    I want to Convert a datetime into some standard format date format,

    ie, 19/12/2008 12:00:00 PM ---->19-Dec-08

    so i am using this function

    Convert(datetime,tbl_Details.UpdateDate), 106) as date,

    IF the date value is null or empty string ,this function returns default date value as 1-jan-00

    i want to return empty string if the date value is null or empty.

    Thanks in advance.

    deesh

  • If the tbl_Details.UpdateDate is NULL, the result will be NULL also. If tbl_Details.UpdateDate is an empty string, the result will be 1 jan 1900.

    Try: Convert(datetime,CASE WHEN tbl_Details.UpdateDate = '' THEN NULL ELSE tbl_Details.UpdateDate END, 106) as date

    Perhaps it's not a good idea to use a character field for storing dates?

  • THANKS NOW WORKING FINE..

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

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