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​
| Type | Parameter | Description | 
|---|---|---|
| Date | date | The given date to extract the field from. | 
| String | field | The field to extract. | 
Returns​
Integer - The value of the specified field within the given date. Note that months are zero-indexed, meaning January is 0, February is 1, and so on.
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