I'm having a little difficulty when working with variables like hours. I would like to know  how I find the result of the number of hours between two variables in the format "hh: mm".
For example:
initiationdate        end date
13:30                      17:00


Tks in advance

Views: 216

Replies to This Discussion

Dear Roberto,

I don't know whether you are using the date and hours format or just the time format like what you just gave here, though your variable name is enddate or initialdate.

Anyway. you can just use a simple function like "EndDate" - (minus sign) "InitialDate.

It should be able to give you an answer. Note that all your date or time fields (inital and end) should be in the same format, e.g. MM/DD/YYYY, hh:mm. If you are having problems, Check first of your fields have the same format!

Just try and see!

Dr Mathe

Hi Gabriel,

Subtracting one date/time from another works but result is number of days in decimal format.
Epi Info 3 has HOURS function that is supposed to return the number of hours between two times (see Help under "Functions and Operations")

The result, however may not always be what you expect. For example, if the duration is 3 hours and 1 minute, HOURS function will return "4".  That is, any portion of an hour is considered a full hour.

If you want to calculate hours or minutes with more precision, or have rounded hours or minutes,
here are some formulae to use (note: 3600 is 60*60 and 1440 is 24*60)

Instead of: HOURS(InititalTime, EndTime)

      (EndTime - InitialTime) * 24
      SECONDS(InititalTime, EndTime) / 3600

Rounded hours:
      ROUND((EndTime - InitialTime) * 24)
      ROUND(SECONDS(InititalTime, EndTime) / 3600)

Instead of: MINUTES(InititalTime, EndTime)

      (EndTime - InitialTime) * 1440
      SECONDS(InititalTime, EndTime) / 60

Rounded minutes:
      ROUND((EndTime - InitialTime) * 1440)
      ROUND(SECONDS(InititalTime, EndTime) / 60)

Attached is an Epi Info 3 mdb file with comparison results.

Hope this helps,
Roy Ing



This was exactly what I was looking for.

Tks VM


© 2015   Created by phConnect Admin.   Powered by

 |  Report an Issue  |  Terms of Service