query for getting yesterday date entry

  • Hi

    I am developing application using windows mobile 6 with vc++ and SQL CE 3.1

    I have used query for getting yesterday date entry ..I am doing minus 1 from system date

    and getting result. but the problem is that when the system date is 1st day of month or year.this query is not working.

    so is there any other logic

    hope for reply.

    thanx

    subodh

  • Could you post the query that you are using?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Could u post your Query then i will reply

  • try this query,it works for me

    select * from testdate where datepart(dd,date1)=datepart(dd,getdate())-1

    so ,i hope this work for you

  • I think this is what you need however without further info I cannot be sure:

    SELECT

    *

    FROM

    sometable

    WHERE

    somedatecolumn >= dateadd(dd,datediff(dd,0,getdate()),-1)

    AND

    somedatecolumn < dateadd(dd,datediff(dd,0,getdate()),0)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply