Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date query 1

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I have a table that has a date/time field formated as mm-dd hh:nn:ss. I simply need a query that will give me yesterdays data between 9am and 6pm. Can anyone help me accomplish this?

Thanks in advance,

Paul
 
Set your criteria under the unnamed datetime field to:
Between DateValue(Date()-1) + 0.375 AND Between DateValue(Date()-1) + 0.75

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Would this also work?
Code:
Between DateAdd("h", DateAdd("d", Date(), -1 ), 9 )
    And DateAdd("h", DateAdd("d", Date(), -1 ), 15 )
 
I think some of the arguments need to by transposed:
Code:
Between DateAdd("h", DateAdd("d", -1 , Date()), 9 )
    And DateAdd("h", DateAdd("d", -1 , Date()), 15 )

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Even a FULL transposition, I guess:
Code:
Between DateAdd("h", 9, DateAdd("d", -1 , Date()))
    And DateAdd("h", 18, DateAdd("d", -1 , Date()))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, that worked perfectly!!!!!! thank you!!!!!
 
A simpler way:
Between DateAdd('h',9,Date()-1) And DateAdd('h',18,Date()-1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PH.

I don't generally like saving keystrokes if losing understandability however...
Code:
Between Date()-0.625 And Date() - 0.25

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top