Primeur Online Docs
Data Shaper
Data Shaper
  • 🚀GETTING STARTED
    • What is Primeur Data Shaper
      • What is the Data Shaper Designer
      • What is the Data Shaper Server
      • What is the Data Shaper Cluster
    • How does the Data Shaper Designer work
      • Designer Views and Graphs
      • Data Shaper Graphs
      • Designer Projects and Sandboxes
      • Data Shaper Designer Reference
    • How do the Data Shaper Server and Cluster work
      • Data Shaper Server and Cluster
      • Data Shaper Server Reference
    • VFS Graph Components
      • DataOneFileDescriptor (DOFD) metadata
      • Passing parameters from Data One Contract to Data Shaper graph
      • Inheriting Data One context attributes in Data Shaper graph
  • DATA SHAPER DESIGNER
    • Configuration
      • Runtime configuration
        • Logging
        • Master Password
        • User Classpath
      • Data Shaper Server Integration
      • Execution monitoring
      • Java configuration
      • Engine configuration
      • Refresh Operation
    • Designer User Interface
      • Graph Editor with Palette of Components
      • Project Explorer Pane
      • Outline Pane
      • Tabs Pane
      • Execution Tab
      • Keyboard Shortcuts
    • Projects
      • Creating Data Shaper projects
      • Converting Data Shaper projects
      • Structure of Data Shaper projects
      • Versioning of server project content
      • Working with Data Shaper Server Projects
      • Project configuration
    • Graphs
      • Creating an empty graph
      • Creating a simple graph
        • Placing Components
        • Placing Components from Palette
        • Connecting Components with Edges
    • Execution
      • Successful Graph Execution
      • Run configuration
      • Connecting to a running job
      • Graph states
    • Common dialogs
      • URL file dialog
      • Edit Value dialog
      • Open Type dialog
    • Import
      • Import Data Shaper projects
      • Import from Data Shaper server sandbox
      • Import graphs
      • Import metadata
    • Export
      • Export graphs to HTML
      • Export to Data Shaper Server sandbox
      • Export image
      • Export Project as Library
    • Graph tracking
      • Changing record count font size
    • Search functionality
    • Working with Data Shaper server
      • Data Shaper server project basic principles
      • Connecting via HTTP
      • Connecting via HTTPS
      • Connecting via Proxy Server
    • Graph components
      • Adding components
      • Finding components
      • Edit component dialog box
      • Enable/disable component
      • Passing data through disabled component
      • Common properties of components
      • Specific attribute types
      • Metadata templates
    • Edges
      • Connecting Components with Edges
      • Types of Edges
      • Assigning Metadata to Edges
      • Colors of Edges
      • Debugging Edges
      • Edge Memory Allocation
    • Metadata
      • Records and Fields
        • Record Types
        • Data Types in Metadata
        • Data Formats
        • Locale and Locale Sensitivity
        • Time Zone
        • Autofilling Functions
      • Metadata Types
        • Internal Metadata
        • External (Shared) Metadata
        • SQL Query Metadata
        • Reading Metadata from Special Sources
      • Auto-propagated Metadata
        • Sources of Auto-Propagated Metadata
        • Explicitly Propagated Metadata
        • Priorities of Metadata
        • Propagation of SQL Query Metadata
      • Creating Metadata
        • Extracting Metadata from a Flat File
        • Extracting Metadata from an XLS(X) File
        • Extracting Metadata from a Database
        • Extracting Metadata from a DBase File
        • Extracting Metadata from Salesforce
        • SQL Query Metadata
        • User Defined Metadata
      • Merging Existing Metadata
      • Creating Database Table from Metadata and Database Connection
      • Metadata Editor
        • Opening Metadata Editor
        • Basics of Metadata Editor
        • Record Pane
        • Field Name vs. Label vs. Description
        • Details Pane
      • Changing and Defining Delimiters
      • Editing Metadata in the Source Code
      • Multi-value Fields
        • Lists and Maps Support in Components
        • Joining on multivalue fields (Comparison Rules)
    • Connections
      • Database Connections
        • Internal Database Connections
        • External (Shared) Database Connections
        • Database Connections Properties
        • Encryption of Access Password
        • Browsing Database and Extracting Metadata from Database Tables
        • Windows Authentication on Microsoft SQL Server
        • Snowflake Connection
        • Hive Connection
        • Troubleshooting
      • JMS Connections
      • QuickBase Connections
      • Hadoop Connections
      • Kafka Connections
      • OAuth2 Connections
      • MongoDB Connections
      • Salesforce Connections
    • Lookup Tables
      • Lookup Tables in Cluster Environment
      • Internal Lookup Tables
      • External (Shared) Lookup Tables
      • Types of Lookup Tables
    • Sequences
      • Persistent Sequences
      • Non Persistent Sequences
      • Internal Sequences
      • External (Shared) Sequences
      • Editing a Sequence
      • Sequences in Cluster Environment
    • Parameters
      • Internal Parameters
      • External (Shared) Parameters
      • Secure Graph Parameters
      • Graph Parameter Editor
      • Secure Graph Parameters
      • Parameters with CTL2 Expressions (Dynamic Parameters)
      • Environment Variables
      • Canonicalizing File Paths
      • Using Parameters
    • Internal/External Graph Elements
    • Dictionary
      • Creating a Dictionary
      • Using a Dictionary in Graphs
    • Execution Properties
    • Notes in Graphs
      • Placing Notes into Graph
      • Resizing Notes
      • Editing Notes
      • Formatted Text
      • Links from Notes
      • Folding Notes
      • Notes Properties
    • Transformations
      • Defining Transformations
      • Transform Editor
      • Common Java Interfaces
    • Data Partitioning (Parallel Running)
    • Data Partitioning in Cluster
      • High Availability
      • Scalability
      • Graph Allocation Examples
      • Example of Distributed Execution
      • Remote Edges
    • Readers
      • Common Properties of Readers
      • ComplexDataReader
      • DatabaseReader
      • DataGenerator
      • DataOneVFSReader
      • EDIFACTReader
      • FlatFileReader
      • JSONExtract
      • JSONReader
      • LDAPReader
      • MultiLevelReader
      • SpreadsheetDataReader
      • UniversalDataReader
      • X12Reader
      • XMLExtract
      • XMLReader
      • XMLXPathReader
    • Writers
      • Common Properties of Writers
      • DatabaseWriter
      • DataOneVFSWriter
      • EDIFACTWriter
      • FlatFileWriter
      • JSONWriter
      • LDAPWriter
      • SpreadsheetDataWriter
      • HIDDEN StructuredDataWriter
      • HIDDEN TableauWriter
      • Trash
      • UniversalDataWriter
      • X12Writer
      • XMLWriter
    • Transformers
      • Common Properties of Transformers
      • Aggregate
      • Concatenate
      • DataIntersection
      • DataSampler
      • Dedup
      • Denormalizer
      • ExtSort
      • FastSort
      • Filter
      • Map
      • Merge
      • MetaPivot
      • Normalizer
      • Partition
      • Pivot
      • Rollup
      • SimpleCopy
      • SimpleGather
      • SortWithinGroups
      • XSLTransformer
    • Joiners
      • Common Properties of Joiners
      • Combine
      • CrossJoin
      • DBJoin
      • ExtHashJoin
      • ExtMergeJoin
      • LookupJoin
      • RelationalJoin
    • Others
      • Common Properties of Others
      • CheckForeignKey
      • DBExecute
      • HTTPConnector
      • LookupTableReaderWriter
      • WebServiceClient
    • CTL2 - Data Shaper Transformation Language
    • Language Reference
      • Program Structure
      • Comments
      • Import
      • Data Types in CTL2
      • Literals
      • Variables
      • Dictionary in CTL2
      • Operators
      • Simple Statement and Block of Statements
      • Control Statements
      • Error Handling
      • Functions
      • Conditional Fail Expression
      • Accessing Data Records and Fields
      • Mapping
      • Parameters
      • Regular Expressions
    • CTL Debugging
      • Debug Perspective
      • Importing and Exporting Breakpoints
      • Inspecting Variables and Expressions
      • Examples
    • Functions Reference
      • Conversion Functions
      • Date Functions
      • Mathematical Functions
      • String Functions
      • Mapping Functions
      • Container Functions
      • Record Functions (Dynamic Field Access)
      • Miscellaneous Functions
      • Lookup Table Functions
      • Sequence Functions
      • Data Service HTTP Library Functions
      • Custom CTL Functions
      • CTL2 Appendix - List of National-specific Characters
      • HIDDEN Subgraph Functions
    • Tutorial
      • Creating a Transformation Graph
      • Filtering the records
      • Sorting the Records
      • Processing Speed-up with Parallelization
      • Debugging the Java Transformation
  • DATA SHAPER SERVER
    • Introduction
    • Administration
      • Monitoring
    • Using Graphs
      • Job Queue
      • Execution History
      • Job Inspector
    • Cluster
      • Sandboxes in Cluster
      • Troubleshooting
  • Install Data Shaper
    • Install Data Shaper
      • Introduction to Data Shaper installation process
      • Planning Data Shaper installation
      • Data Shaper System Requirements
      • Data Shaper Domain Master Configuration reference
      • Performing Data Shaper initial installation and master configuration
        • Creating database objects for PostgreSQL
        • Creating database objects for Oracle
        • Executing Data Shaper installer
        • Configuring additional firewall rules for Data Shaper
Powered by GitBook
On this page
  • createDate
  • dateAdd
  • dateDiff
  • extractDate
  • extractTime
  • getYear
  • getMonth
  • getDay
  • getHour
  • getMinute
  • getSecond
  • getMillisecond
  • randomDate
  • today
  • zeroDate
  • trunc
  • truncDate
  1. DATA SHAPER DESIGNER
  2. Functions Reference

Date Functions

PreviousConversion FunctionsNextMathematical Functions

Last updated 1 month ago

When you work with a date, you may use functions that process dates. In these functions, sometimes a format pattern of a date or any number must be defined. Also a locale and time zone can have an influence on their formatting.

  • For detailed information about the date formatting and/or parsing, see .

  • For detailed information about locale, see .

  • For detailed information about time zones, see .

Remember that numeric and date formats are displayed using the system value Locale or Locale specified in the defaultProperties file, unless other Locale is explicitly specified. Similarly for Time zone. For more information on how Locale and Time zone may be changed in the defaultProperties, see .

Here we provide the list of the functions.

createDate

date createDate( integer year, integer month, integer day );
date createDate( integer year, integer month, integer day, string timeZone );
date createDate( integer year, integer month, integer day, integer hour, integer minute, integer second );
date createDate( integer year, integer month, integer day, integer hour, integer minute, integer second, string timeZone );
date createDate( integer year, integer month, integer day, integer hour, integer minute, integer second, integer millisecond );
date createDate( integer year, integer month, integer day, integer hour, integer minute, integer second, integer millisecond, string timeZone );

The function createDate() creates a date using provided year, month (numbered from 1), day of month, hour, minute, second, millisecond and time zone. If any of the above mentioned parameters is missing, value is set to zero. If the time zone is missing, the default time zone is used. If one or more of specified parameters is null, the function fails.

Example 124. Usage of createDate

  • The function createDate(2013, 7, 31) returns a date corresponding to the 31 July 2013 0:00 using the default time zone. The summer/winter time is taken into account. For example, the expression returns 30 July 2013 22:00 GMT in time zone GMT+1 using the summer time.

  • The function createDate(2013, 10, 4, "GMT+3") returns 4 October 2013 0:00 GMT+3. It is the same as 3 October 2013 21:00 GMT+0.

  • The function createDate(2009, 2, 13, 23, 31, 30) returns 13 February 2009 23:31:30 in the default time zone. For example the expression corresponds to 13 February 2009 22:31:30 GMT if the default time zone is GMT+1.

  • The function createDate(2009, 2, 13, 23, 31, 30, "GMT-1") returns 14 February 2009 0:31:30 GMT.

  • The function createDate(2009, 2, 13, 23, 31, 30, 123) returns 13 February 2009 23:31:30.123 in the default time zone. For example the expression corresponds to 13 February 2009 22:31:30.123 GMT if the default time zone is GMT+1.

  • The function createDate(2009, 2, 13, 23, 31, 30, 124, "GMT-1") returns 14 February 2009 0:31:30.124 GMT.

See also: str2date

dateAdd

date dateAdd( date arg, long amount, unit timeunit );

The dateAdd() function adds a number of time units to the date and returns a new date. Parameter arg is the date to which the number of time units is added. Parameter amount defines the number of units to be added. The unit parameter defines the unit of the second function parameter. The unit argument can be one of the following: year, month, week, day, hour, minute, second, millisec. The unit must be specified as a constant. It can neither be received through an edge nor set as a variable. The function returns the new resulting date. If one of the arguments is null, the function fails with an error.

Example 125. Usage of dateAdd

  • Let us set up date d to 13 February 2009 23:31:30 GMT.

  • The function dateAdd(d, 1, year) returns 2010-02-13 23:31:30 GMT.

  • The function dateAdd(d, 1, month) returns 2009-03-13 23:31:30 GMT.

  • The function dateAdd(d, 1, day) returns 2009-02-14 23:31:30 GMT.

  • The czDate is 30.3.2014 00:00:00 in the time zone Europe/Prague.

  • The function dateAdd(czDate, 24, hour) returns 31.3.2014 01:00:00 CEST.

  • The function dateAdd(czDate, 1, day) returns 31.3.2014 00:00:00 CEST

  • The ukDate is 2014-03-30 00:20:00 in the time zone Europe/London.

  • The function dateAdd(ukDate, 41, minute) returns 2014-04 02:01:00 in the time zone Europe/London.

  • The function dateAdd(ukDate, 1, hour) returns 2014-03-30 02:20:00 in the time zone Europe/London.

  • The function dateAdd(ukDate, 1, day) returns 2014-03-31 00:20:00 in the time zone Europe/London.

See also: createDate, dateDiff

dateDiff

long dateDiff( date later, date earlier, unit timeunit );

The dateDiff() function returns the difference of two date variables in a specified time units. The later and earlier parameters represent a later and earlier date respectively. The difference of two dates is expressed in defined time units. The unit can be one of the following: year, month, week, day, hour, minute, second, millisec. The unit must be specified as a constant. It can be neither received through an edge nor set as variable.

If the unit is hour, minute, second or millisec, it counts the difference in the same way as it would be measured using stopclock. If the unit is day, month or year, the difference affected by winter/summer time turn is calculated differently. See the examples below!

The result is a longnumber. The result of the function is truncated: two date variables with a difference of 40hours yield a difference of 1 days. If one of the given argument is null, the function fails with an error.

Be aware! Adjusting for the daylight saving time - winter/summer time affects the results of dateDiff(). Different countries switch between summer time and winter time on different days. The function dateDiff() uses the time zone of your operating system.

Example 126. Usage of dateDiff

  • The function dateDiff(2008-06-18, 2001-02-03, year) returns 7. But, dateDiff(2001-02-03, 2008-06-18, year) returns -7.

  • Let’s call 2009-02-13 23:31:30 GMT+0 as d1 and 2011-01-10 20:12:33 as d2.

  • The function dateDiff(d2, d1, year) returns 1.

  • The function dateDiff(d2, d1, month) returns 22.

  • The function dateDiff(d2, d1, day) returns 695.

  • The variable L2 is 2014-03-30 02:01:00 in the time zone Europe/London. The variable L1 is 2014-03-30 00:59:00 in the time zone Europe/London. The function dateDiff(L2, L1, minute) returns 2.

  • Set 2014-03-30 00:15:00 with the time zone Europe/London as london1 and set 2014-03-30 02:15:00 with the same time zone as london2. The function dateDiff(london2, london1, hour) returns 1.

  • Set 2014-03-30 00:15:00 with the time zone America/New_York as ny1 and set 2014-03-30 02:15:00 with the same time zone as ny2. The function dateDiff(ny2, ny1, hour) returns 2.

  • Set 2014-02-10 10:15:00 with the time zone America/New_York as nyFeb10 and 2014-02-10 10:15:00 with the time zone Europe/London as ukFeb10. The function dateDiff(nyFeb10, ukFeb10, hour) returns 5.

  • Set 2014-03-10 10:15:00 with the time zone America/New_York as nyMar10 and 2014-03-10 10:15:00 with the time zone Europe/London as ukMar10. The function dateDiff(nyMar10, ukMar10, hour) returns 4.

  • Set 2014-03-08 12:14:16 with the time zone America/New_York as ny21 and 2014-03-09 12:14:16 with the same time zone as ny22.

  • The function dateDiff(ny22, ny21, millisec) returns 82800000.

  • The function dateDiff(ny22, ny21, second) returns 82800.

  • The function dateDiff(ny22, ny21, minute) returns 1380.

  • The function dateDiff(ny22, ny21, hour) returns 23.

  • The function dateDiff(ny22, ny21, day) returns 1 if processing runs on machine with the same time zone as the data (America/New_York). The function returns 0 if processing runs on machine with a different time zone (e.g. Europe/London). Time in the time zone Europe/London is turned on the different day than in time zones in US. If you would process data having the time zone America/New_York using the time zone America/Los_Angeles, you would get 0 or 1.

See also: dateAdd, str2date

extractDate

date extractDate( date arg );

The extractDate function takes a date argument and returns only the information containing year, month, and day values. The function’s argument is not modified by the return value. If the input argument is null, the function returns null. The default locale and default time zone are applied.

Example 127. Usage of extractDate

  • Let’s call 13 February 2009 23:31:30 GMT+0 as d.

  • The function extractDate(d) returns 2009-02-13 0:00:00 GMT+0 provided the default time zone is GMT+0. If the default time zone is GMT+1, the function will return 2009-02-14 0:00:00 GMT+1. (The result corresponds to 2009-02-13 23:00:00 GMT+0.)

See also: extractTime, str2date

extractTime

date extractTime( date arg );

The extractTime() function takes a date argument and returns only the information containing hours, minutes, seconds, and milliseconds. The function’s argument is not modified by the return value. If the input argument is null, the function returns null. The default locale and default time zone are applied.

Example 128. Usage of extractTime

  • Let’s call 13 February 2009 23:31:30 GMT+0 as d.

  • The function extractTime(d) returns 23:31:30 provided the default time zone is GMT+0. If the default time zone is GMT+1, the function will return 0:31:30.

See also: extractDate, str2date

getYear

integer getYear( date arg );
integer getYear( date arg, string timeZone );

Example 129. Usage of getYear

  • Let’s call 2011-01-01 1:05:00 GMT as d.

  • The function getYear(d) returns 2011. The default time zone is used.

  • The function getYear(d, "GMT+0") returns 2011.

  • the function getYear(d, "GMT-3") returns 2010. There have not been a midnight in the GMT-3 yet.

See also: date2str, getMonth, getDay, getHour, getMinute, getSecond, getMillisecond, str2date

getMonth

integer getMonth( date arg );
integer getMonth( date arg, string timeZone );

Example 130. Usage of getMonth

  • Let’s call 2011-01-01 1:05:00 GMT as d.

  • The function getMonth(d) returns 1 provided the default time zone is GMT+1.

  • The function getMonth(d, "GMT+0") returns 1.

  • The function getMonth(d, "GMT-3") returns 12. There have not been a midnight in the GMT-3 yet.

See also: date2str, getYear, getDay, getHour, getMinute, getSecond, getMillisecond, str2date

getDay

integer getDay( date arg );
integer getDay( date arg, string timeZone );

Example 131. Usage of getDay

  • Let’s call 2011-01-01 1:05:00 GMT as d.

  • The function getDay(d) returns 1 provided the default time zone is GMT+1.

  • The function getDay(d, "GMT+0") returns 1.

  • The function getDay(d, "GMT-3") returns 31. There have not been a midnight in the GMT-3 yet.

See also: date2str, getYear, getMonth, getHour, getMinute, getSecond, getMillisecond, str2date

getHour

integer getHour( date arg );
integer getHour( date arg, string timeZone );

Example 132. Usage of getHour

  • Let’s call 2011-01-01 1:05:00 GMT as d.

  • The function getHour(d) returns 2 provided the default time zone is GMT+1.

  • The function getHour(d, "GMT+0") returns 1.

  • The function getHour(d, "GMT-3") returns 22.

See also: date2str, getYear, getMonth, getDay, getMinute, getSecond, getMillisecond, str2date

getMinute

integer getMinute( date arg );
integer getMinute( date arg, string timeZone );

Example 133. Usage of getMinute

  • Let’s call 2011-01-01 1:05:00 GMT as d.

  • The function getMinute(d) returns 5, provided the default time zone is GMT+1.

  • The function getMinute(d, "GMT+0") returns 5.

  • The function getMinute(d, "GMT-9:30") returns 35.

See also: date2str, getYear, getMonth, getHour, getDay, getSecond, getMillisecond, str2date

getSecond

integer getSecond( date arg );
integer getSecond( date arg, string timeZone );

Example 134. Usage of getSecond

  • Let’s call 2011-01-01 1:05:02 GMT as d.

  • The function getSecond(d) returns 2.

  • The function getSecond(d, "GMT+0") returns 2.

  • The function getSecond(d, "GMT-4") returns 2.

See also: date2str, getYear, getMonth, getDay, getHour, getMinute, getMillisecond, str2date

getMillisecond

integer getMillisecond( date arg );
integer getMillisecond( date arg, string timeZone );

Example 135. Usage of getMillisecond

  • Let’s call 2011-01-01 1:05:02.123 GMT as d.

  • The function getMillisecond(d) returns 123.

  • The function getMillisecond(d, "GMT+0") returns 123.

  • The function getMillisecond(d, "GMT-4") returns 123.

See also: date2str, getYear, getMonth, getDay, getHour, getMinute, getSecond, str2date

randomDate

date randomDate( date startDate, date endDate );
date randomDate( long startDate, long endDate );
date randomDate( string startDate, string endDate, string format );
date randomDate( string startDate, string endDate, string format, string locale );
date randomDate( string startDate, string endDate, string format, string locale, string timeZone );

Example 136. Usage of randomDate

  • Let’s call 2011-01-01 0:00:00 as date1 and 2012-01-01 0:00:00 as date2. The function randomDate(date1, date2) returns for example 2011-06-19.

  • The function randomDate(123456789000L, 1266103890000L) returns for example 2009-06-20.

  • The function randomDate("2011-11-11", "2012-12-12", "yyyy-MM-dd") returns for example 2012-09-01.

  • The function randomDate("10 octobre 2011", "11 novembre 2011", "dd MMMM yyyy", "fr.FR") returns for example 2011-10-14.

  • The function randomDate("2011-01-11", "2011-08-12", "yyyy-MM-dd", "en.US", "GMT-5") returns for example 2011-05-14.

See also: random, randomBoolean, randomGaussian, randomInteger, randomLong, randomString, randomUUID, setRandomSeed

today

date today(  );

The today() function accepts no argument and returns current date and time.

Example 137. Usage of today The today() function returns, for example, 2013-11-06 12:32:15 provided today is 6 November 2013 and the time is 12:32:15.

See also: zeroDate

zeroDate

date zeroDate(  );

The zeroDate() function accepts no argument and returns 1.1.1970 0:00:00 GMT.

See also: today

trunc

The function trunc is deprecated. It returns a value and modifies the argument at the same time.

truncDate

The function truncDate is deprecated. It returns a value and modifies the argument at the same time.

The getYear() function returns the year of arg. If the argument is null, the function returns null. If the timeZone argument is null or the argument is missing, the function uses the default .

The getMonth() function returns the month of the year (numbered from 1) of arg. If the argument is null, the function returns null. If the timeZone argument is null or the argument is missing, the function uses the default .

The getDay() function returns the day of the month of arg. If the argument is null, the function returns null. If the timeZone argument is null or the time zone argument is missing, the function uses the default .

The getHour() function returns the hour of the day (24-hour clock) of arg. If the argument is null, the function returns null. Otherwise the specified time zone is used. If the timeZone argument is null, the function uses the default .

The getMinute() function returns the minute of the hour of arg. If the argument is null, the function returns null. If the timeZone argument is null or the parameter is not present, the function uses the default .

The getSecond() function returns the second of the minute of arg. If the argument is null, the function returns null. If the timeZone argument is null or the argument is not present, the function uses the default .

The getMillisecond() function returns the millisecond of the second of arg. If the argument is null, the function returns null. If the timeZone argument is null or the parameter is not present, the function uses the default .

The randomDate() function returns a random date between startDate and endDate. These resulting dates are generated at random for different records and different fields. They can be different for both records and fields. The return value can also be startDate or endDate. However, it cannot be the date before startDate nor after endDate. If one of the given dates is null, the function fails with an error. If the format is null or the function does not have the format parameter, the default value is used. If the timezone is null or the function does not have the timezone parameter, the default is used. If the locale is null or the field is missing, the default is used.

Time Zone
Time Zone
Time Zone
Time Zone
Time Zone
Time Zone
Time Zone
Time Zone
Locale
Locale
Time Zone
Engine Configuration
Date and Time Format