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

Calculating hours and also minutes 1

Status
Not open for further replies.

mintman

IS-IT--Management
Mar 5, 2007
66
US
Hello,
I have two date fields Created date and modified date.
Suppose if Create Date = 1/22/2007
modified date = 1/23/2007 then I used formula

whileprintingrecords;
numberVar dur := datediff("s",{@Date1}, {@Date2});
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

hhmmss := totext(hrs,"00") + ":" + totext(min,"00")+ ":" + totext(sec,"00");

If I use this for above two fiels I get 24 hrs.


But now there are other 2 fields time 1 and time 2

Field 1 Fields 2 Field 3 Field 4
1/22/2007 22:30:00 1/23/2007 02:00:00

now I want to create formula to show events were only 3 hours and 30

Any suggestions on this please.
 
If these are date and time fields, then you change your formulas to:

//{@datetime1}:
datetime({table.field1},{table.field2})

//{@datetime2}:
datetime({table.field3},{table.field4})

Use these instead of the date formulas in the datediff function for the variable dur.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top