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

select statement for printdate to equal 'last' Saturday

Status
Not open for further replies.

koolskins

IS-IT--Management
Nov 22, 2003
79
US
CR10 running against an Informix database...
What is the select statement syntax to have a report's printdate automatically be set to the last Saturday's date regardless of which day of the week it is run on? The report is currently taking the printdate - 42 and giving a six week chart rolling forward. To date, I've been manually setting the printdate before I run the report, but I would like to automate this step. Thanks in advance.

R
 
You can find the day of the week using
Code:
Datepart("w", {your_date})
The result will be a number 1 to 7, with Sunday as 1 and Saturday as 7, unless you set something else as firstDayOfWeek.

To get from a date to the previous Saturday, do something like
Code:
if @DayOfWeek then {The_Date}
else {The_Date} - @DayOfWeek

This assumes that the first formula ws a formula field called @DayOfWeek

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I think you could use the following for printdate, which I believe is the same as currentdate, to get the previous Saturday:

currentdate - dayofweek(currentdate)

-LB

 
Thanks guys. You got me pointed in the right direction. Much appreciated.

R.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top