Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Explain query

Author  Topic 

learntsql

524 Posts

Posted - 2009-09-04 : 02:14:26
Could u please explain following query
"DATEADD(dd,DATEDIFF(dd,0,date_column),0)"
ThankQ.

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-09-04 : 02:20:19
Hi

DATEADD()
Function is adds or subtracts a specified time interval from a date.
DATEDIFF
Returns the number of date and time boundaries crossed between two specified dates.

SELECT DATEDIFF(dd,getdate()-1,getdate())

SELECT DATEDIFF(dd,0,getdate())

SELECT DATEADD(dd,DATEDIFF(dd,0,getdate()),0)




-------------------------
R...
Go to Top of Page

ra.shinde
Posting Yak Master

103 Posts

Posted - 2009-09-04 : 02:27:40
DATEADD(dd,DATEDIFF(dd,0,date_column),0)
This will return date in date_column with default time i.e. 12:00:00 AM

Rahul Shinde
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-09-04 : 04:32:42
Hi,

select dateadd(d,datediff(d,0,getdate()),0) this will return date only, what ever datefield(8/3/2009 12:34:345 ) it returns only date .
Go to Top of Page
   

- Advertisement -