DateTime Variables
The DateTime variable type holds the representation of a date and/or time in the format of the number of milliseconds since January 1, 1970. This variable type is currently supported in the new transformation engine only.
You can safely manipulate date-time values in your data without the need for manual editing or custom rules to do so.
The Move rule (version 2) automatically converts the date into DateTime format (for EDI and Database).
In conjunction with this variable type, several new Actions are available in the Ruleset. This table lists Ruleset Actions that support the DateTime variable type.
Action | Description |
---|---|
AddDateTime | Adds two DateTime types and returns a new DateTime value. |
AddDateTimeWithFields | Adds specified values to a DateTime and returns a new DateTime value. |
CreateDateTime | Creates a DateTime. |
CreateDateTimeFromMilliseconds | Creates a DateTime from milliseconds since 1970, 00:00:00 GMT. |
CreateDateTimeFromString | Creates a DateTime from a string. |
DateTimeEquals | Checks to see if two DateTimes are equal and returns a boolean result. |
DateTimeNotEquals | Checks to see if two DateTimes are not equal and returns a boolean result. |
FormatDateTime | Used to convert a DateTime to a formatted string. |
GetCurrentDateTime | Gets current Date and Time. Returns a DateTime value. |
GetDayOfMonth | Gets the day of the month from a DateTime, and returns a numeric value from 1 to 31. Returns null if the specified DateTime is null. |
GetDayOfWeek | Gets the day of the week for the DateTime, and returns a numeric value from 1 to 7. |
GetDayOfYear | Gets the day of year field value. Return null if the specified date time is null. |
GetDaysBetween | Gets the number of days between two DateTime values, and returns a numeric value. |
GetHourOfDay | Gets the hour of the day from a DateTime and returns a numeric value from 0 to 23. Returns null if the specified DateTime is null. |
GetMilliseconds | Gets the number of milliseconds since 1970, 00:00:00 GMT for the DateTime, and returns numeric value. Returns null if the specified DateTime is null. |
GetMinuteOfHour | Gets the minute of the hour, from 0 to 59. |
GetMonthOfYear | Gets the month of the year from a DateTime and returns a numeric value from 1 to 12. Returns null if the input is null. |
GetSecondOfMinute | Gets the second of the minute from a DateTime and returns a numeric value from 0 to 59. Returns null if the input is null. |
GetYear | Gets the year from a DateTime and returns a numeric value. |
SubtractDateTime | Subtracts two DateTimes and returns a new DateTime. |
Creating a DateTime Variable
- Click Add Variable.
- Type the name you wish to give the variable.
- Select DateTime from the Type drop-down.
- Click OK to complete this task.
Result: The new variable now appears (identified as ) as an option in
the Variables pane.
Example
This simple example shows how you might use a DateTime variable with several Actions. We will use the DateTime variable to set an initial value for a specific date - 12192000. We will then take that variable and add one day using another action. Finally we will format and write the output.
- CreateDateTimeFromString
- AddDateTimeWithFields
- FormatDateTime
But first we must create the DateTime variable from the Ruleset editor.
This variable, named "DT", is now available for use from the Variables pane.
Action: CreateDateTimeFromString
- Define Inputs (12192000)
- Define the pattern (mmddyyyy)
- Use "DT" as output.
Action: AddDateTimeWithFIelds
- Define inputs, using "DT"
- For DayOfMonth, define as “1”. For this example, we are simply adding one day to the initial DateTime.
- Again, use "DT" as output.
Action: FormatDateTime
- Define inputs, using "DT".
- Define the pattern. (mmddyyyy)
- Write the string out to target.
Now that we have our three Action used as Rule in the Ruleset, we can run the transformation and test the output.
Result: Initial source DateTime of 12192000 is written to target (Field 1) as 12202000.