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!

Date field calcutation

Status
Not open for further replies.

flyerone

Programmer
Mar 18, 2002
11
0
0
US
I need to subtract days from a DateTime field and I also need to subtract hours from a DateTime field. I need to check after I subtract the days from the DateTime to see if the new day falls on the weekend and if so use Mondays date.
does anyone have formulas to do this. Thanks
 
Dateadd{"D",-3,{DateTimeField}) will subtract 3 days from the field. Replace the "D" with an "H" and you are subtracting hours.

After you build that formula, use this one to move to the next Monday if the day is Saturday or Sunday, otherwise leave it where it is:

If DayofWeek({@YourFormula})= 1 then Dateadd("d",1,{@YourFormula}) else if DayofWeek({@YourFormula}) = 7 then Dateadd("d",2,{@YourFormula}) else {@YourFormula} Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
Thanks dgillz. These formulas are working great, thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top