Skip to main content
Version: 8.1

dateExtract

This function is used by Ignition's Expression language.

Description​

Returns an integer value that is the value of the specified date field within the given date. The field must be a string, and must match one of these values:

  • ms
  • second
  • sec
  • minute
  • min
  • hour
  • hr
  • day
  • week
  • month
  • year
  • dayofweek
  • dayofyear
note

Months are returned zero-indexed. That is, January is month 0, February is month 1, and so on. To get a month index starting at 1, simply add 1 to the function result.

Syntax​

dateExtract(date, field)

  • Parameters

    • Date date - The given date.

    • String field - The field to extract the value from.

  • Results

    • Integer - The value of the specified field within the given date.

Examples​

Code Snippet
dateExtract(toDate("2003-9-14 8:00:00"), "year") //returns 2003
Code Snippet
dateExtract(toDate("2009-1-15 8:00:00"), "month") //returns 0
Code Snippet
dateExtract(toDate("2008-1-24 8:00:00"), "month") + 1 //returns 1