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 Difference Formula 1

Status
Not open for further replies.

bluraz

MIS
Aug 18, 2005
32
US
Crystal XI

I need to calculate hours past midnight on Friday. Normally I just do a DateDiff formula. My question is, do you know of a way to 'hard-code' midnight into a formula?

Usually I would do something like this...

if dayofweek ({Dispatch.ACTUALFINISH}) > 5 and {Dispatch.Consignee_ID} = '40C1'
then datediff ('s', {@NullTripStart}, {Dispatch.ACTUALFINISH})/3600

I need to replace the "{@NullTripStart}" with something that would start the clock at midnight on Friday's.
 
I think you could replace {@NullTripStart} with:

datetime(date({Dispatch.ACTUALFINISH}-dayofweek({Dispatch.ACTUALFINISH})+6),time(0,0,0))

This assumes that the actual finish is on Friday or Saturday of the same week.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top