Skip to content

Date functions

Date functions are provided to manipulate FastStats date fields.

Today

Returns today’s date shifted by n days.

Expression
Today(n)

For example:

  • Today(0) is today’s date
  • Today(1) is tomorrow
  • Today(-1) is yesterday
  • Today(-7) is one week ago

AgeDays

Age of date in days relative to today.

Expression
AgeDays([Date])

For example, if today is 30th May 2007 and date1 is 20th May 2007, AgeDays(date1) = 10.

AgeQuarters

Age of date in 3 calendar month periods relative to today

Expression
AgeQuarters([Booking Date])

For example, if today is 12 October 2011 and date1 = 05 January 2011, AgeQuarters (date1) = 3.

AgeWeeks

Age of date in whole weeks relative to today

Expression
AgeWeeks([Booking Date])

For example, if today is 30 May 2007 and date1 is 20 May 2007, AgeWeeks(date1) = 1.

AgeMonths

Age of date in months relative to today

Expression
AgeMonths([Booking Date])

For example, if today is 30 May 2007 and date1 is 20 May 2006, AgeMonths (date1) = 12.

AgeYears

Age of date in years relative to today

Expression
AgeYears([Booking Date])

For example, if today is 30 May 2007 and date1 = 20 May 2005, AgeYears (date1) = 2.

DateDay

Day of date 1.. 31

Expression
DateDay([Booking Date])

DateWeek

Week of date 1..53

Expression
DateWeek([Booking Date])

DateMonth

Month of date 1=Jan, 2=Feb, … 12=Dec

Expression
DateMonth([Booking Date])

DateQuarter

Quarter of date 1=Q1, 2=Q2, 3=Q3, 4=Q4

Expression
DateQuarter([Booking Date])

DateYear

Year of date e.g. 2005

Expression
DateYear([Booking Date])

DayOfWeek

Day of date 1=Monday, 2=Tuesday, … 7=Sunday

Expression
DayOfWeek([Booking Date])

Date2Days

The number of days since 0000

Expression
Date2Days(2006,01,01)

DateDiff

Calculates [Date] - [Date] measured in the specified units (years, quarters, months, weeks, days).

Expression
DateDiff( [Date], [Date], "Units")

Units specifier is optional. If missing, the default units are days. If only one date is specified, the given date is compared to today.

For example:

  • DateDiff([DepartureDate],[Booking Date],”Days”) is the number of days between departure and booking.

  • DateDiff([DepartureDate],20051231,”Days”) is the number of days between departure and 31 Dec 2005.

  • DateDiff([DepartureDate],Today(0),”Days”) is the number of days until departure.

  • DateDiff([DepartureDate],[Booking Date],”Weeks”) is the number of weeks between departure and booking.

The zero band extends in both a forward and backward direction from the reference date. An optional final parameter can be set to 1 to return missing value if the first date is after the second date. This ensures that results are only returned when there is a positive value, which corresponds to when the date parameters are in chronological order.

For example:

DateDiff expression showing positive-value-only result

MakeDate

Makes a constant date from numbers

Expression
MakeDate(Years, Months, Days)

For example:

Expression
MakeDate(2007,08,22)

The expression below returns the start of the year in which the booking was made.

Expression
MakeDate(DateYear([Booking Date],01,01))

DateShift

Shift a time by a number of units (years, quarters, months, weeks, days).

Expression
DateShift([Date],[Date],"Units")

For example:

  • DateShift([BookingDate],30,”Days”) calculates 30 days after booking.
  • DateShift([DepartureDate],-30,”Days”) calculates 30 days before departure.
  • DateShift([DOB],18,"Years") calculates 18th birthday

DayOfYear

Calculates the day number in the year 1 .. 366

Expression
DayOfYear([date])

For example, the expression below equals 5.

Expression
DayOfYear(20070105)

BuildDate

The FastStats system build date shifted by n days.

Expression
BuildDate(n)

For example:

  • BuildDate(0) = build date
  • BuildDate(-1) = day before build date

Legacy date functions

These are provided for backwards compatibility, but have been superceded by more useful date functions.

Day

Number of days from year 0000 to date.

Expression
Day([Booking Date])

Week

Number of weeks from year 0000 to date.

Expression
Week([Booking Date])

Month

Number of months from year 0000 to date.

Expression
Month([Booking Date])

Year

Number of years from year 0000 to date.

Expression
Year([Booking Date])