Results 1 to 3 of 3

Thread: Date Difference

  1. #1
    Join Date
    Jun 2011
    Posts
    6

    Unanswered: Date Difference

    Dear All,

    we have 2 db and i try to retrview yesterdays records from both db,i used

    where 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

  2. #2
    Join Date
    Jul 2011
    Posts
    9
    Can you just run a single datediff statement for both databases like this?

    WHERE DATEDIFF(d, cst.DateCreated, (GETDATE() - 1)) = 0

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Is this other DB sitting in a different time zone? What do you get for
    Code:
    select getdate()
    on both servers?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •