Sep 27, 2002 #1 tsherfy Programmer Dec 23, 2000 20 US Can someone tell me the correct syntax for retrieving just the date portion of a datetime field?
Sep 27, 2002 #2 RiverGuy Programmer Jul 18, 2002 5,011 US I asked this question once before and got a great response: thread183-318979 Upvote 0 Downvote
Sep 27, 2002 #3 tlbroadbent MIS Mar 16, 2001 9,982 US 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: http://tlbroadbent.home.attbi.com/prog.htm faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions. Upvote 0 Downvote
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: http://tlbroadbent.home.attbi.com/prog.htm faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
Sep 27, 2002 #4 RiverGuy Programmer Jul 18, 2002 5,011 US Hey Terry, I linked him to one of your answers as well ..... Upvote 0 Downvote
Sep 27, 2002 #5 tlbroadbent MIS Mar 16, 2001 9,982 US Riverguy, I see that. Too bad I didn't remember it. Terry L. Broadbent - DBA Computing Links: http://tlbroadbent.home.attbi.com/prog.htm faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions. Upvote 0 Downvote
Riverguy, I see that. Too bad I didn't remember it. Terry L. Broadbent - DBA Computing Links: http://tlbroadbent.home.attbi.com/prog.htm faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
Sep 27, 2002 Thread starter #6 tsherfy Programmer Dec 23, 2000 20 US Excellent! Thanks to all who replied! Tim Upvote 0 Downvote