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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax to Compare Dates

Status
Not open for further replies.

ddevil

Technical User
Feb 14, 2006
49
US
I have the following date comparison:

If stStat2 = "Open" And Year(stSchedDate) > Today Then

do something.....

What I really want is if the stSchedDate > the beginning of the month prior to the month we are in.

If the stSchedDate was 11/24/2008 then this statement would be true because the begining of the month prior to December, the month we are in, would be 11/1/2008.

Any ideas what the syntax would be for this?
 
G'day ddevil,

Code:
stSchedDate = DateAdd("d",1-Day([stSchedDate ]),DateAdd("m",-1,[stSchedDate ]))

will set stSchedDate to the 1st of the previous month. Also will work over 08/09 boundaries which could be a drama with your month() plan...

Good luck!

JB
 
if the stSchedDate > the beginning of the month prior to the month we are in
If stStat2 = "Open" And stSchedDate > DateSerial(Year(Now), Month(Now) - 1, 1) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top