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!

Help! I need hours between two dates?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I posted this before but didn't get an answer I understood. Ihave two situations...
1. I need to calculate the hours elapsed between two fields. For example, field 1 is 3/3/00 11:00 am and field 2 is 3/3/00 at 5:00 pm. I need to know that six hours passed.

2. I need to know the days that pass between two dates. for example, field one is 3/3/00 and field 2 is 3/5/00. I need to know that two days passed between them.

sorry to be a pain, but I need help. I havea deadline this week and these are my two problems.
 
kstrout: To answer your 2nd question first the solution is to subtract one date from the other - the answer is the number of days between them e.g.
{field2}-{field1} will result in 2

The answer to your 1st question is dependent upon the version of CR you are using. The lastest version (8+) includes the ability to use Basic Syntax in your formula so you can use the Basic function DateDiff() e.g.
DateDiff("s",{field1},{field2}) will result in the number of intervals between the dates where in this case the interval is seconds - denoted by the "s"

If you are on an earlier version you may have to resort to the fact that a datetime field subtracted from another datetime field results in the number of days and fractions of a day between them. e.g. in your example 0.25 You will then need to convert to seconds by multiplying by 86400 (number of seconds in a day) so this would give you 21600 seconds or 6 hours.

Hope this helps David C. Monks
david.monks@chase-international.com
Accredited Crystal Decisions Enterprise Partner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top