September 24, 2004 at 7:52 am
HI
how do I get the GETDATE() function to return only the date without the time ?
or is there another way to get the current date in a dd/mm/yy format ?
thanks
September 24, 2004 at 7:59 am
You have to CONVERT it to a string. Refer to BOL for more information on CONVERT.
SELECT CONVERT(VARCHAR(8), GETDATE(), 1)
-SQLBill
BOL=Books OnLine=Microsoft SQL Server's HELP
Installed as part of the Client Tools
Found at Start>Programs>Microsoft SQL Server>Books OnLine
September 27, 2004 at 10:27 am
In T-SQL there is no DATE type; only DATETIME. The CONVERT to a string produces a string (Duh!) but if you convert this string back to a DATETIME, the time portion of the DATETIME will default to midnight (Beginning of the day).
Also, you might want to get into the habit of using CURRENT_TIMESTAMP instead of GetDate(). They are equivalent. The preference lies in the fact that CURRENT_TIMESTAMP is an official function in SQL while GetDate() is a Microsoft variance from the standard.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply