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!

Date Formula

Status
Not open for further replies.

DirtyB

Programmer
Mar 13, 2001
159
US
Can anyone help me get started writing a date formula? I have a SQL Field (datetime datatype) that stores the date something happened (called ActionDate). I need on my Crystal Report the ActionDate and then the date of the following Saturday. The ActionDate could be any day of the week. So for example, if my ActionDate is 9/12/2001 438p.m. then I need a formula that returns 9/15/2001. Any help is much appreciated.

Thanks
 
Hi,

You should be able to do this with a simple formula...

numbervar d := DayOfWeek ({datetime_field});
datevar dt := date(datetime_field}) + (7-d);
totext(dt,"ddd yyyy/MM/dd")

PS. I have tested it !!

Geoff
 
Hi,

PPS. I should have declared the variables as local !!

Geoff
 
Geoff:

THANK YOU! Thank you so much. I have seen the DayofWeek function before but I couldn't find much on how to use it. Just for future references, it will return a 1 for Sunday and a 7 for Saturday then right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top