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

date DAY syntax

Status
Not open for further replies.

Halfcan

Technical User
Dec 8, 2002
214
US
Hello,

I have a string param called DateRange that depending on the string choosen, generates a start date, and an End date
to generate the report.
My problem is that the end date is displaying one day too far.
example: I choose "Last Month"
It returns: 02-01-03 to 03-01-03

This is my code in select expert:
{?DateRange} = "Last Month",
CDate(Year(CurrentDate), Month(CurrentDate) -1, 1) To CDate(Year(CurrentDate), Month(CurrentDate), 1),

I want it to return 02-01-03 to 02-28-03

I seems my DAY is a problem. does anyone know how I can display the correct day?
v8.5
Thanks,

Andy
 
I use the following two formulas, and then reference them in the record selection criteria:

@start
If {?Predefined Date Range} = "Last Month" Then
If Month (CurrentDate) = 1 Then
DateTime((Year(CurrentDate)-1),12,1,0,0,0)
Else
DateTime(Year(CurrentDate),Month(CurrentDate)-1,1,0,0,0)

@end
If {?Predefined Date Range} = "Last Month" Then
If Month (CurrentDate) = 1 Then
DateTime(Year(CurrentDate)-1,12,1,23,59,59)
Else
DateTime(Year(CurrentDate),Month(CurrentDate),1,23,59,59)-1

Note that I'm comparing against datetimes, so I build it out accordingly.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top