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!

Creating a formula to calculate time difference.

Status
Not open for further replies.

Devikl

IS-IT--Management
Aug 22, 2007
16
US
I am having difficulties when trying to create a formula that will calculate the difference in hours-minutes-seconds. Here is the senario:

I am trying to find out the time span between an exam being dictated to transcribe.

Please help!
 
DateDiff includes the ability to find the difference between two date-time values, in seconds. Once you have the value in seconds, use division and remainders to get it into minutes and hours.

I'd advise doing it step by step. Also use SEARCH to check for recent examples.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Hi Madawc,

Thank you very much for your fast response. I am a new user and this may be a really stupid question but here is my formula:

{v_MROTranscribed.RSD_DATE} - {v_MRODictation.RSD_DATE}

How do I use the DateDiff on this formula to get the difference in date and time?

Thank you.
 
Devikl,

I think you need to reverse it - 1st start date then end date:

DateDiff ("s", {v_MRODictation.RSD_DATE},{v_MROTranscribed.RSD_DATE})

Andy
 
I am now able to get the time difference in seconds, how do i create the formula to translate seconds to hour,minutes and seconds?

Here is my formula:

datediff("s",{v_MRODictation.RSD_DATE},{v_MROTranscribed.RSD_DATE})
 
I can get the time difference in hours and minutes, how can I modify my formula to show seconds as well?

Here is my formula:

numberVar dur := datediff("s",{v_MRODictation.RSD_DATE},{v_MROTranscribed.RSD_DATE}); //get the seconds between 2 dates
numberVar hrs;
numberVar min;
stringVar hhmm;

hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
hhmm :=totext(hrs,"00") + ":" + totext(min,"00");

hhmm
 
lbass showed where to find it a couple of messages above:


whileprintingrecords;
numberVar dur := datediff("s",{v_MRODictation.RSD_DATE},{v_MROTranscribed.RSD_DATE}); //get the seconds between 2 dates
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");

hhmmss
 
Thank you everyone I finally can see the results I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top