Return only the Date from a SQL Server DateTime
On SQL Server 2008 and higher, you should CONVERT to date:
SELECT CONVERT(date, getdate())
On older versions, you can do the following:
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date))
for example
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
gives me
2008-09-22 00:00:00.000
Links: https://stackoverflow.com/questions/113045/how-to-return-only-the-date-from-a-sql-server-datetime-datatype
for example
select cast(getdate() as date)
Comments
Post a Comment