Date and Time Methods

Date and Time Methods


For the methods described in this article to work, you must use a Matillion ETL variable that is defined as a DateTime type and it must have a valid default value.

Matillion ETL offers a set of proprietary methods for use with Date and DateTime variables to ease the burden of handling the various formats and common calculations placed on the user. The new methods are described in brief below.

Method Description
.now() A new date object with a current server timestamp.
.add("units", integer) Add a specified length of time to a timestamp.
.format("pattern") Change the format of a timestamp.
.parse("pattern",stringDate) Parse a piece of a timestamp according to a given pattern.

Each of the above methods can be used with DateTime variables set in Matillion through Manage Environment Variables. See Using Variables for more information. e.g.

The above methods are useful in combination such that a created date is immediately acted upon by another method. For example:

${dt.add("days", 3)}
Can be written as

${"days", 3)}


.now() creates a new date object that takes the server's time and keeps it as a timestamp. The server time is determined by the instance Matillion ETL is running on. For example, in a Python component:


.add("units", integer)

.add() uses a predefined datetime and adds a specified time to it. The allowed units are:

  • "seconds"
  • "minutes"
  • "hours"
  • "days"
  • "weeks"
  • "months"
  • "years"

Where the integer argument states the number of those units to add to the datetime. Furthermore, negative integers can be given to take time away from a datetime. For example:

${"days", -1)}

This will give a timestamp for yesterday.



.format will take a timestamp and reformat it into one of two styles according to the following Pattern arguments:

  • "yyyy/MM/dd"
  • "HH:mm:ss.SSS"

The two patterns returning a datetime as either a date or a time. For example:


This will return the current date on the server.

.parse("Pattern", "string")

.parse() takes a string and converts it into a date object.  For example:

${dt.parse("yyyy", "2016")}

Here the string "2016" is turned into a date object with the format "yyyy" and is stored in the $dt variable.