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

Predefined date

Status
Not open for further replies.

quake1969

Technical User
Dec 21, 2011
5
US
Hi:

I've been spinning my wheels on this. I have a report that I need to run based on the last effective day of the previous month. So if it's december 15th, I want it to run for November 30, if it's January 23rd, it should run for December 31 or should this last date for on a sunday, it should pick the previous day, so if 12/31 fell on a sunday, it would pick 12/30...any help on this would be greatly appreciated.
 
There is a function calle Lastfullmonth

In select expert just use

{YourDatefield} >= maximum(lastfullmonth)

Alternatively you can build a foumula

Date(year(currentdate), month(currentdate), 1) -1

But I am not sure why you want to do that.

Ian
 
Thanks for the help Ian. I greatly appreciate it
 
I think you would have to use:

datevar lastday := Date(year(currentdate),month(currentdate),1)-1;
if dayofweek(lastday)=1 then
lastday-1 else
lastday

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top