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

Date and time sum

Status
Not open for further replies.

Andyherm

Technical User
Nov 29, 2006
25
GB
Hi.
I'm a newbie with Crystal (v11) and I'm trying to setup a formula to output a time to fix in hhmm format.
An example of the inputs would be 10/11/2006 12:00 - 10/11/2006 11:30 which I would need to display 00:30.
Does anyone know what the formula would be to accomplish this?
Much appreciated,
Andy.
 
DateDiff("n", date1, date2) would give you the sum in minutes. Best to first display the answer, confirming it is doing what you want, and then work on displaying it.

For a similar situation I did
Code:
if @MyTime < 60 
then totext(@MyTime, "00") & " mn"
else totext(truncate((@MyTime/60)))  "hr, "
      & totext(remainder({@MyTime , 60), "00")  & " mn"

This is not the same as your display, obviously. But you should be able to adapt it.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thanks Madawc that gave me the number of minutes difference. I should be able to figure out converting this into hhmm format.
Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top