October 4, 2005 at 11:45 am
using straight TSQL, what is an easy way to 'select' a datetime field and show only the date?
Thanks for any and all help.
Russ...
October 4, 2005 at 11:53 am
Select dateadd(D, 0, Datediff(D, 0, GetDate()))
October 4, 2005 at 11:58 am
Or this: SELECT CONVERT( varchar, GETDATE(), 101)
I wasn't born stupid - I had to study.
October 4, 2005 at 12:16 pm
Here's a link that will give you other ways of getting just the date part of a DateTime data type:
http://www.sql-server-helper.com/functions/get-date-only.aspx
October 6, 2005 at 7:20 am
Here is an another approach:
declare @d datetime
set @d = getdate()
select cast(cast(@d-0.5 as int) as datetime)
This is almost equivalent to
select CAST(FLOOR(CAST(@d AS DECIMAL(12, 5))) AS DATETIME)
Bye
Gabor
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply