June 23, 2009 at 12:56 am
Hi,
Can you suggest some efficient way of stripping the time part from Datetime column.
Eg.
Input : 2008-01-01 12:12:12:223
Output: 2008-01-01 00:00:00:000
June 23, 2009 at 1:24 am
DECLARE @TheDate DATETIME
SET @TheDate = '2008-01-01 12:12:12:223'
SELECT dateadd(dd, datediff(dd,0, @TheDate),0)
See http://sqlinthewild.co.za/index.php/2007/11/05/datetime-manipulation/
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 23, 2009 at 2:44 am
Hi,
And mm-dd-yyyy to dd-mm-yyyy?
June 23, 2009 at 2:58 am
Don't understand your question. A datetime has no defined format, it's a date, format is a string property. The format that you see in queries is defined by your regional settings and, if you want to see something else, you can use the CONVERT function to convert the date to a varchar in the format that you want to see it as.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 23, 2009 at 3:01 am
Thanks a lot . i got it :w00t:
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply