April 28, 2003 at 3:45 pm
I have date column in regular formatas datetime in my table.But when i run my stored procedure which return 5 columns including date column,i want ot get only date i,e 4/28/2003.For that i am using following function for date
DATEADD(d, DATEDIFF(d, 0, hdate), 0).
But i am getting date as 4/28/2003 00:00:00
How to to get only date in my results?
can anyone help in this
April 28, 2003 at 3:49 pm
Select Convert(char(8),GetDate(),101)
Or then
Select Convert(char(8),HDate,101)
April 28, 2003 at 3:51 pm
Oops should have been
Select Convert(char(10),GetDate(),101)
April 28, 2003 at 3:51 pm
all this (DATEADD(d, DATEDIFF(d, 0, hdate), 0)) does is return the value of hdate with a time of midnight (00:00:00.000). what you want to use is something like:
convert(char(10),[datetime],<style>) Look in books online to determine what style of the date you want.
Gregory Larsen, DBA
If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples
Gregory A. Larsen, MVP
April 28, 2003 at 4:46 pm
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply