Date range to return records from two part months

PeteB

Registered User.
Local time
Today, 03:09
Joined
Mar 15, 2016
Messages
78
I need an expression to enter into a "Date Entered" field of a report, or into a query, to return a set of records between 24th of the previous month and 23rd of the current month. Can anyone help please?
 
make a form, add 2 text boxes, txtStartDate, txtEndDate (locked = yes so users cant change them)

then add a combo box, with the months
and a text box for the year.
User picks the month and the year is default to current.

after update event of cboMo, is sets the dates in start/end dates.
txtEndDate = cboMo & "/23/" & txtYr
txtStartDate = dateAdd("m",-1,txtEndDate )
txtStartDate = dateAdd("d",1,txtSTartDate )

then all queries run using these 2 dates
select * from table where [date] between forms!frmRpt!txtStartDate and forms!frmRpt!txtEndDate
 
Last edited:
select * from table where [datefield] between DateSerial(Year(DateAdd("m",-1,Date())), Month(DateAdd("m",-1,Date())), 24) And DateSerial(Year(Date()), Month(Date()), 23)
 
arnelgp

Thanks for your input yesterday. I entered select * from table where [datefield] between DateSerial(Year(DateAdd("m",-1,Date())), Month(DateAdd("m",-1,Date())), 24) And DateSerial(Year(Date()), Month(Date()), 23) into the DateJoined field but am told there is a syntax error. I have fiddled with the syntax but I can't see where the error is. Do you have time to look at this again please?
 
create a query, dismissed the Show Table pop and select SQL on the ribbon. copy and paste the code in the sql builder window.

you have the replace "table" with correct table name and [datefield] with [DateJoined].
 

Users who are viewing this thread

Back
Top Bottom