Skip to main content

Time & Date Calculations

Business Intelligence

A
Written by Andy Temple
Updated over 3 weeks ago

It is recommended that in all instances where calculations are required on a date, that the date is converted to an integer – then for display purposes converted back to a standard date format.

Once a date is in integer form it can then be used in further calculations (i.e. add 7 to calculate a week later or within an IF statement.

TODAY

TODAY returns an integer for today’s date

Related Topics

DATE

Purpose:

Returns the integer value of the date. This is useful if combined with get() or set() for report stores, or for comparison with other dates.

Syntax

DATE(dd,mm,yyyy)

Example of DATE Calculation

DATESTRING

datestring("dd/mm/yyyy") Returns the integer value of the date string.

WEEKDAY

weekday(a)Returns the number of the day in the week (where Sunday=1), if 'a' is the integer value of a date. For example, 11-Feb-04 is a Wednesday, so weekday(date(11,02,2004)) returns 3.

WEEKDAYS

Weekday(decimal-date1,decimal-date2)returns an integer for the number of weekdays (i.e. excluding weekends) between two dates

DAY

day(a)Returns the date in the month if 'a' is the integer value of a date.

MONTH

Purpose:

Converts a character string of numbers into an decimal

Syntax

MONTH(integer)

Returns the number of the month if passed the integer value of a date.

Example of MONTH Calculation

YEAR

year(a) Returns the year (as a four-digit integer) if 'a' is the integer value of a date.

time

time$("12345")Would return 03:45:23

Did this answer your question?