Get Yesterday's Date

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I have a field in my table called Date_Modified, with the Data Type of
Date/Time, and whenever the record is modified the field gets the current
date and time, Now I want to run a query that will include only records that
were updated yesterday, but I can not run it because since the field stores
the time value as well, it doesn't return any record; however it does work
if I enter the criteria as follows:
*11/10/2003*
But I want to have an expression that will have yesterday's date, how do I
do it. ?


Thanks,

Scott
 
Add your field to the query.
Then in the Field row change it from Date_Modified to:
Format([Date_Modified],"Short Date")
and in the Criteria row:
Date()-1
 
jmonty said:
Add your field to the query.
Then in the Field row change it from Date_Modified to:
Format([Date_Modified],"Short Date")
and in the Criteria row:
Date()-1

-----Original Message-----
I have a field in my table called Date_Modified, with the Data Type
of Date/Time, and whenever the record is modified the field gets the
current date and time, Now I want to run a query that will include
only records that were updated yesterday, but I can not run it
because since the field stores the time value as well, it doesn't
return any record; however it does work if I enter the criteria as
follows: *11/10/2003*
But I want to have an expression that will have yesterday's date,
how do I do it. ?

No need to format the date field; just drop the decimal places or take
the DateValue:

Int([Date_Modified])

or

DateValue([Date_Modified])
 
Thanks, Dirk


Dirk Goldgar said:
jmonty said:
Add your field to the query.
Then in the Field row change it from Date_Modified to:
Format([Date_Modified],"Short Date")
and in the Criteria row:
Date()-1

-----Original Message-----
I have a field in my table called Date_Modified, with the Data Type
of Date/Time, and whenever the record is modified the field gets the
current date and time, Now I want to run a query that will include
only records that were updated yesterday, but I can not run it
because since the field stores the time value as well, it doesn't
return any record; however it does work if I enter the criteria as
follows: *11/10/2003*
But I want to have an expression that will have yesterday's date,
how do I do it. ?

No need to format the date field; just drop the decimal places or take
the DateValue:

Int([Date_Modified])

or

DateValue([Date_Modified])

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top