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.
| Author |
Topic |
|
hey001us
Posting Yak Master
185 Posts |
Posted - 2010-05-13 : 19:49:45
|
| Is this correct way?SELECt DATEADD(DD, DATEDIFF( DD, 1, GETDATE()),0),DATEADD( ms, 86399996, DATEADD(DD, DATEDIFF( DD, 1, GETDATE()),0))Output: 2010-05-13 00:00:00.000 As StartDay, 2010-05-13 23:59:59.997 EndDayhey |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-14 : 02:53:25
|
quote: Originally posted by hey001us Is this correct way?SELECt DATEADD(DD, DATEDIFF( DD, 1, GETDATE()),0),DATEADD( ms, 86399996, DATEADD(DD, DATEDIFF( DD, 1, GETDATE()),0))Output: 2010-05-13 00:00:00.000 As StartDay, 2010-05-13 23:59:59.997 EndDayhey
This is not reliable and may change depends on the version you are using. If you want to find out all data of yesterday regardless of time, usewhere date_col>=dateadd(day,datediff(day,0,getdate())-1,0) anddate_col<dateadd(day,datediff(day,0,getdate()),0) MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|