DateDuration Function
With this function, you can do two kinds of data calculations:
- Calculate the number of hours, days, or other time unit between two different input dates. In this case, input fields are dates of the same date format.
- Calculate a new date by adding a given number of hours, days, or other time unit to a given date. In this case, the first input is the start date. The second input is a positive or negative number of units (e.g. days, hours) to be added to the date. The result is the new date in the same format as the start date.
In both cases, two input fields (StartDate and EndDate) are required
Parameters
Source format |
Defines the date format of the source data, such as yyyy.MM.dd or dd MMM yyyy HH:mm:ss |
Unit | Defines the time unit for the date calculation. Possible values include seconds, minutes, hours, days, weeks, months, and years. |
Time zone |
Defines the time zone for date functions, taking daylight saving into consideration. For example, you can calculate the difference between two dates in locations with and without daylight saving (i.e., Eastern Savings Time and India Time) and the result will factor the difference in the number of days.
If no time zone is specified, then the system time zone is used. |
Language |
Sets the input and output language.
The language should be set as a combination of a standard language code and of a standard country code. They can be found at http://www.loc.gov/standards/iso639-2/php/English_list.php and at https://en.wikipedia.org/wiki/ISO_3166-2. The pattern is <language>_<country>, also possible is only <language>. For example, English can be set as If <country> or both codes are not set, for the missing code will be set the corresponding system default value. |
The function DateDuration recognizes the letters of the standard SimpleDateFormat, which can be found under
http://download.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html (not all are useful for this function).
The letters q, Q, and v are Jedox Integrator-specific enhancements of the standard SimpleDateFormat.
Below is an overview of the most used letters for the function DateDuration:
Letter |
Meaning |
Result for 31.12.2014 15:35:20 |
d |
Day in month |
31 |
M |
Month in year |
MM: 12, MMM: Dec, MMMM: December |
y |
Year |
yyyy: 2014, yy: 14 |
H |
Hour in day (0-23) |
15 |
m |
Minute in hour |
35 |
s |
Second in minute |
20 |
Examples
Input1 | Input2 | Unit | Result |
01.01.2012 | 100 | days | 10.04.2012 |
10.04.2012 | 01.01.2012 | days | -100 |
12.04.1967 | 23.02.2012 | years | 44 |
31.01.2012 | 3 | months | 30.04.2012 |
15.10.2012 08:00 | 15.10.2012 17:00 | minutes | 540 |
31.12.1899 | 40909 | days | 01.01.2012 |
31.12.1899 | 01.01.2012 | days | 40909 |
The last two samples can be used for the conversion of a date to a timestamp in Excel.
Updated December 9, 2024