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 & Time Difference

Status
Not open for further replies.

BrickMad

Technical User
May 2, 2003
2
NZ
Is there anyway to calculate a time difference in minutes when you have to take into account the date and the time? For example I have a Visit Time and a Visit Date and an Exit Time and an Exit Date. I want to know what the difference is in minutes between the Visit time if it is for example the 1st January 2008 at 15:00 and the 3rd January 2008 15:03 in this case the difference will be 2883 minutes. However if I take the difference between just the visit time then it will be only 3 mins.

Any ideas?
 
Calculate the diff in days, then add the difference to the lowest date (using _add_days() )and perform the time calc you already have?

Ties Blom

 
I need to calculate the difference in time between two dates in minutes. How do I do that? I need the value to be returned as a integer.
 
Assuming you're using Impromptu, can you not just use the DAY, HOUR and MINUTE functions on the difference between the two date-time fields?

If your fields are Start and End, then Impromptu turns
Code:
day(End-Start) * 24 * 60 + hour(End-Start) * 60 + minute(End-Start)

into SQL on SQL server as
Code:
(extract(DAY FROM (T1."End" - T1."Start"))) * 24 * 60 + (extract(HOUR FROM (T1."End" - T1."Start"))) * 60 + (extract(MINUTE FROM (T1."End" - T1."Start")))


The implementation of time functions in Impromptu seem to be pretty basic.

soi la, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top