Page 1 of 1

Date and Time into Hours

PostPosted: Fri Nov 06, 2015 8:12 am
by ajhunt
Hi all, is there a plugin which can give me the difference in hours from 1 date and time to another date and time? example being like:

StartDateTime = 15/10/2015 09:00
EndDateTime - 06/11/2015 15:00

Difference in hours being xxxxx hours

Thanks anyone for any help. Best regards

Re: Date and Time into Hours

PostPosted: Fri Nov 06, 2015 8:59 am
by dpayer
How precise do you need to be?

For example: if one point is 9:00PM Feb. 27, 2016 and the next is 8:00AM March 1, 2016, you will need to account for leap year, adding one day.

Accuracy to the hour? or to the minute?

To get the difference in number of days from one day to another, look at the actions DateToNum & NumToDate

From Helpfile:

DateToNum

Purpose:
Convert a formatted date to a number that can be used in mathematical calculations. The result, a numeric date, represents the number of days since December 30, 1899. A numeric date can be converted back into a formatted date with the NumToDate Action.

Category:
Control

Syntax:
DateToNum "date" "format" "variable"

date

A formatted date consisting of two or three numbers, separated by “\”, “/” or “-”. Year values between 0 and 99 are assumed to be in the current century. The date must match the format parameter below.

format
A string that identifies the format of the date. For example:

m/d/y
Month/Day/Year

d/m/y
Day/Month/Year

y/m/d
Year/Month/Day

Default
Use the system’s default date format.

variable

The name of the variable to store the converted date number.

Example:
The following example calculates the number of days since December 15th, 2004:

DateToNum "12/15/2004" "m/d/y" "[StartDate]"
DateToNum "[DateShort]" "Default" "[Today]"
Math "[Today]-[StartDate]" "0" "[Result]"
AlertBox "Answer" "It has been [Result] days since 12/15/2004"



You can then s convert days to hours/minutes and find the difference in hours within the day between the two times.

Re: Date and Time into Hours

PostPosted: Fri Nov 06, 2015 9:22 am
by ajhunt
Many thanks David - I just need to the day/hour so I will play with your suggestion - many thanks again for your time and help. best regards.