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 |
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2011-07-21 : 09:57:00
|
| Dear All,we have 2 db and i try to retrview yesterdays records from both db,i usedwhere cst.DateCreated >=DATEADD(dd,DATEDIFF(dd,0,GETDATE())-1,0)AND cst.DateCreated <DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)In one DB its pull exactly yesterday record and in another DB it pulls day before yesterday records.Why this difference and how to fix this.Any help will be highly appreciated.Many Thanks.Reagrds,SG |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-07-21 : 10:00:40
|
| Check the system date on the system that seems to be giving you the wrong data. select getdate();Are the two servers in the same time-zones? |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-07-21 : 10:03:55
|
| Are you sure?Run select DATEADD(dd,DATEDIFF(dd,0,GETDATE())-1,0), DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)in both databases.also check the actual date of the a row selected from both datbases.Could be something to do with datatypes or compatability mode but I can't think of what would do this.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|