Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Date portion of datetime data type

Status
Not open for further replies.

tsherfy

Programmer
Dec 23, 2000
20
US
Can someone tell me the correct syntax for retrieving just the date portion of a datetime field?
 
I asked this question once before and got a great response:

thread183-318979
 
There are many ways.

Convert(varchar(10), datetimecol, 120) returns a character string of "yyyy-mm-dd".

Convert(varchar(8), datetimecol, 1) returns a character string of "mm/dd/yy".

Convert(varchar(6), datetimecol, 12) returns a character string of "yymmdd".

convert(datetime, convert(int, datetimecol)) returns a datetime column with time set to zero or 12:00 AM. (i.e., 2002-09-28 00:00:00.000)

Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Hey Terry, I linked him to one of your answers as well .....
 
Excellent! Thanks to all who replied!

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top