DML functions: Date and time
The following functions are available:
addDays
addSeconds
dayOfWeek/dayOfYear
getDate
/ getDay / getMonth / getYear
getHours
/ getMinutes / getSeconds / getTime / getUTC
getDateAndTime
getDateAndTimeNoUTC
convertDateAndTimeUTCOffset
makeDateAndTime
nbDays
nbSeconds
Date and Time
Century pattern
Century flag pattern
Year pattern
Month pattern
Day pattern
Hours pattern
Minutes pattern
Seconds pattern
12 hour clock pattern
Time Zones
UTC Sign pattern
UTC hours pattern
UTC minutes pattern
XML pattern
Time precision pattern
Separators pattern
Predefined formats
Variable Size-Fixed Size
addDays
Description
|
addDays adds the number of days that you specify to a date.
|
Syntax
|
addDays(date,
number_of_days)
|
Return
|
Date
|
Parameters
|
date
Specify the initial Date value
|
number_of_days
Enter an Integer that specifies the number of days that addDays adds to date.
|
Example
|
The following example adds five days to the specified date.
addDays('2000-03-28',
5) returns '2000-04-02 00:00:00+00:00'.
|
addSeconds
Description
|
addSeconds adds the number of seconds that you specify to a date.
|
Syntax
|
addSeconds(date, number_of_seconds)
|
Return
|
Date
|
Parameters
|
date
Date value including hours:minutes:secondsD. Specify the initial.
|
number_of_seconds
Enter an Integer that specifies the number of seconds that addseconds adds to date.
|
Example
|
The following example adds 30 seconds to the specified date.
addSeconds('2000-03-28
00:00:00', 30) returns '2000-03-28 00:00:30+00:00'.
|
dayOfWeek
Description
|
dayOfWeek returns as Integer the day of the week for a Date expression.
Monday is equal to 1, and Sunday is equal to 7.
|
Syntax
|
dayOfWeek(date)
|
Return
|
Integer
|
Parameters
|
date
Specify the Date to display the chronological number of that day of the week.
|
Example
|
The following example calculates the day of the week for a given date, and converts it to an Integer. Thursday, the
fourth day of the week in the year 2000 was 23 March, so dayOfWeek returns the value 4.
dayOfWeek('2000-03-23
10:25:37+02:00')returns 4.
|
dayOfYear
Description
|
dayOfYear returns Julian day of the year (1 January
is equal to 1)
from a date expression.
|
Syntax
|
dayOfYear(date)
|
Return
|
Integer
|
Parameters
|
date
Specify the Date to display the chronological number of that day of the year.
|
Example
|
The following example calculates the day of the year for a given date, and converts it to an Integer. The 83rd day of the year in the year 2000 was 23 March, so dayOfYear returns
the value 83.
dayOfYear('2000-03-23
10:25:37+02:00') returns 83.
|
getDate
Description
|
getDate returns the date from an expression that specifies the date and time.
|
Syntax
|
getDate(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time.
|
Example
|
The following example returns the date from the date and time expression.
getDate('2000-03-23 10:25:37+02:00')
returns 20000323.
|
getDateAndTime
Description
|
getDateAndTime returns the current date and time of your operating system. If you specified a date in the RuleManager startprocess command, the Function returns this processing date.
|
Syntax
|
getDateAndTime()
|
Return
|
Date
|
Parameters
|
None
|
Example
|
getDateAndTime() returns the current system date and time.
|
getDateAndTimeNoUTC
Description
|
getDateAndTimeNoUTC returns the current date and time of your operating system ignoring UTC.
|
Syntax
|
getDateAndTimeNoUTC()
|
Return
|
Date
|
Parameters
|
None
|
Example
|
getDateAndTimeNoUTC() returns the current system date and time.
|
convertDateAndTimeUTCOffset
Description
|
convertDateAndTimeUTCOffset converts a date and time from one timezone to another one.
|
Syntax
|
convertDateAndTimeUTCOffset(date, timezone)
|
Return
|
Date
|
Parameters
|
date
Enter the date that needs to be converted to the new timezone.
|
timezone
Enter the desired timezone. The timezone parameter format is "Suh:um" where "S" is the sign.
|
|
Example
|
convertDateAndTimeNoUTC() returns the current system date and time.
|
getDay
Description
|
getDay returns the day of the month from an expression that specifies the date and time.
|
Syntax
|
getDay(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time
|
Example
|
The following example returns the day from the date and time expression.
getDay('2000-03-23
10:25:37+02:00') returns 23.
|
getHours
Description
|
getHours returns the hour from an expression that specifies the date and time.
|
Syntax
|
getHours(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time
|
Example
|
The following example returns the hours from the date and time expression.
getHours('2000-03-23
10:25:37+02:00') returns 10.
|
getMinutes
Description
|
getMinutes returns the minutes from an expression that specifies a date and time.
|
Syntax
|
getMinutes(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time.
|
Example
|
The following example returns the minutes from the date and time expression.
getMinutes('2000-03-23
10:25:37+02:00') returns 25.
|
getMonth
Description
|
getMonth returns the month from an expression that specifies the date and time.
|
Syntax
|
getMonth(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time.
|
Example
|
The following example returns the month from the date and time expression.
getMonth('2000-03-23
10:25:37+02:00') returns 3.
|
getSeconds
Description
|
getSeconds returns the seconds from an expression that specifies the date and time.
|
Syntax
|
getSeconds(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time.
|
Example
|
The following example returns the seconds from the date and time expression.
getSeconds('2000-03-23
10:25:37+02:00') returns 37.
|
getTime
Description
|
getTime returns the time from an expression that specifies the date and time.
|
Syntax
|
getTime(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time.
|
Example
|
The following example returns the time from the date and time expression.
getTime('2000-03-23
10:25:37+02:00') returns 102537.
|
getUTC
Description
|
getUTC returns the UTC from an expression that specifies the date and time.
|
Syntax
|
getUTC(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time.
|
Example
|
The following example returns the UTC from the date and time expression.
getUTC('2000-03-23
10:25:37+02:00') returns 200.
|
getYear
Description
|
getYear returns the year from an expression that specifies the date and time. The year
is always expressed in four characters.
|
Syntax
|
getYear(dateAndTime_expression)
|
Return
|
Integer
|
Parameters
|
dateAndTime_expression
Specify a Date and time.
|
Example
|
The following example returns the year from the date and time expression.
getYear('2000-03-23
10:25:37+02:00') returns 2000.
|
makeDateAndTime
Description
|
makeDateAndTime makes a date from the parameters that you specify.
|
Syntax
|
makeDateAndTime(year,month,day,hours,minutes,seconds,utc)
|
Return
|
Date
|
Parameters
|
year
Enter an Integer that specifies the millennium and century.
|
month
Enter an Integer that specifies the month.
|
day
Enter an Integer that specifies the day of the month.
|
hour
Enter an Integer that specifies the hour.
|
minutes
Enter an Integer that specifies the minute of the hour.
|
seconds
Enter an Integer that specifies the number of seconds.
|
utc
Enter an Integer that specifies the coordinated universal time.
|
Examples
|
makeDateAndTime(1998,02,28,09,10,00,01) returns '1998-02-28
09:10:00+01:00'.
makeDateAndTime(2000,2,29,9,10,0,1) returns '2000-02-29 09:10:00+01:00'.
makeDateAndTime(2000,02,28,00,00,00,00) returns
'2000-02-28 00:00:00+00:00'.
|
nbDays
Description
|
nbDays calculates the difference between two dates.
|
Syntax
|
nbDays(date1, date2)
|
Return
|
Integer
- Positive
if date2 > date1
- Negative
if date1 > date2
|
Parameters
|
date1
Specify a start Date
|
date2
Specify an end Date
|
Example
|
The following example calculates the number of days between the first date and the second date.
nbDays('2000-03-28',
'2000-04-02') returns 5.
|
nbSeconds
Description
|
nbSeconds - calculates
the difference between two times, in seconds.
|
Syntax
|
nbSeconds(date1, date2)
|
Return
|
Integer
- Positive
if date2 > date1
- Negative
if date1 > date2
|
Parameters
|
date1
Specify a start Date and time
|
date2
Specify an end Date and time
|
Example
|
The following example calculates the number of seconds between the first date (date and time) and the second
date (date and time).
nbSeconds('2005-11-03
17:07:25', '2005-11-03 17:07:27') returns 2.
|
Date and Time
The following tables describe the way Date and Time are formatted in DML components when used in Business Documents and DML instructions.
Century pattern
CC |
The century with two digits |
Reading 1999 with CC, returns 19.
Reading 0999 with CC, returns 09.
|
C |
The century with two digits or one bit while formatting date, and if it is feasible
|
Reading 1999 with C, returns 19.
Formatting 01/31/0999 with C, writes 9.
Reading 0999 with C, returns 9.
Reading 999 with C, returns 99.
|
When it is not specified, the default Century is the 20th.
Century flag
Use this Century pattern to support the Cobol format.
c |
The Century flag, 0 for 19XX, 1 for 20XX |
Reading 1999 with c, returns 0.
Reading 2099 with c, returns 1.
|
This pattern is not intended to be used by the end user. It was only introduced to manage compatibility with the Cobol date pattern.
Year
YY |
The year with two digits |
Reading 01 with YY, returns 01.
Formatting 1911 with YY, writes 11.
|
YYYY |
The year with four digits |
Reading 2001 with YYYY, returns 10. |
Y |
The year on two digits or one bit while formatting date, and if it is feasible
|
Reading 10 with Y, returns 10.
Formatting 01/31/09 with Y, writes 9.
Reading 09 with Y, returns 9.
Reading 1999 with Y, returns 19.
|
When it is not specified, the default year is 2000
.
Month
MM |
The month with two digits |
Reading 01 with MM, returns 01.
Formatting 11 with MM, writes 11.
Reading 15 with MM, raises an error.
|
M |
The month with two digits or one bit while formatting date, and if it is feasible |
Reading 10 with M, returns 10.
Reading 09 with M, returns 9.
Formatting 01 with M, writes 1.
Reading 1: with M, writes 1.
Reading 13 with M, raises an error.
|
When it is not specified, the default month is January.
While reading, if the month found is >12 or <1, the application raises an error.
Day
DD |
The day with two digits |
Reading 01 with DD, returns 01.
Formatting 11 with DD, writes 11.
Reading 32 with DD, raises an error.
|
D |
The day with two digits or one bit while formatting date, and if it is feasible |
Reading 10 with D, returns 10.
Reading 09 with D, returns 9.
Formatting 01 with D, writes 1.
Reading 1: with D, writes 1.
Reading 32 with D, raises an error.
|
When it is not specified, the default day is the 1st.
While reading, if the day found is >31 or <1, the application raises an error.
Hours
hh |
The hours with two digits |
Reading 01 with hh, returns 01.
Formatting 11 with hh, writes 11.
Reading 24 with hh, raises an error.
|
h |
The hours with two digits or one bit while formatting date, and if it is feasible |
Reading 10 with h, returns 10.
Reading 09 with h, returns 9.
Formatting 01 with h, writes 1.
Reading 1: with h, returns 1.
Reading 24 with h, raises an error.
|
When it is not specified, the default hour is 0h.
While reading, if the hour found is >23 or <0, the application raises an error.
Minutes
mm |
The minutes with two digits |
Reading 01 with mm, returns 01.
Formatting 11 with mm, writes 11.
Reading 61 with mm, raises an error.
|
m |
The minutes with two digits or one bit while formatting date, and it is feasible |
Reading 10 with m, returns 10.
Reading 09 with m, returns 9.
Formatting 01 with m, writes 1.
Reading 1: with m, returns 1.
Reading 61 with m, raises an error.
|
When it is not specified, the default minute is 0.
While reading, if the minutes found are >59 or <0, the application raises an error.
Seconds
ss |
The seconds with two digits |
Reading 01 with ss, returns 01.
Formatting 11 with ss, writes 11.
Reading 61 with ss, raises an error.
|
s |
The seconds with two digits or one bit while formatting date, and it is feasible |
Reading 10 with s, returns 10.
Reading 09 with s, returns 9.
Formatting 01 with s, writes 1.
Reading 1: with s, returns 1.
Reading 61 with s, raises an error.
|
When it is not specified, the default seconds is 0.
While reading, if the seconds found are >59 or <0, the application raises an error.
12 hours clock
xx |
am or pm
When xx is specified, the software converts the hours in 12 hours clock.
While reading, am and/or pm can be accepted.
|
Reading 01am with hhxx, returns 01.
Reading 01pm with hhxx, returns 13.
Reading 12am with hhxx, returns 12.
Reading 12pm with hhxx, returns 00.
Formatting 01 with hhxx, writes 01am.
Formatting 13 with hhxx, writes 01pm.
Reading 13am with hhxx, raises an error.
Reading 00pm or 00am with hhxx, raises an error.
|
While reading, if the hours found are >12 or <1, the application raises an error.
Time Zones
The following tables describe the way Time Zones are formatted in DML components when used in Business Documents and DML instructions.
UTC Sign
S or + |
+ or - |
With 11:42:00+01:00, S means +. |
When it is not specified, the default UTC sign is +.
UTC hours
uh |
The UTC hours with two digits |
With 11:42:00+01:00, uh means 01. |
When it is not specified, the default UTC hour is 0h.
While reading, if the UTC hours found are >23 or <0, the application raises an error.
UTC minutes
um |
The UTC minutes with two digits |
With 11:42:00+01:00, um means 00. |
When it is not specified, the default UTC minutes are 00.
While reading, if the minutes found are >59 or <0, the application raises an error.
XML pattern
With the XML pattern for time zone, the time zone is not mandatory while converting a String to a Date.
zzzzzz |
The UTC offset with 6 characters:
- First, + or - for the UTC sign,
- Then, 2 digits for the UTC hours,
- Then, : as a separator,
- And then 2 digits for the UTC minutes.
While reading, it also accepts Z.
|
With 11:42:00+01:00, zzzzzz means +01:00.
Reading 114200+00:00 with hhmmsszzzzzz, UTC offset is +00:00.
Reading 114200Z with hhmmsszzzzzz, UTC offset is +00:00.
Reading 114200 with hhmmsszzzzzz, UTC offset is +00:00.
Reading 114200whatever with hhmmsszzzzzz, raises an error.
|
When it is not specified, the default UTC offset is +00:00.
As a shortcut:
Z |
The UTC offset on 6 characters (as zzzzzz), but replace +00:00 by Z when formatting a date, or accepts Z when reading a date. |
With 11:42:00+01:00, Z means +01:00.
Reading 11:42:00Z with hh:mm:ssZ, returns 11:42:00+00:00.
Formatting 11:42:00+00:00 with hh:mm:ssZ, writes 11:42:00Z.
Reading 114200+00:00 with hh:mm:ssZ, UTC offset is +00:00.
Reading 114200whatever with hh:mm:ssZ, raises an error.
|
Time precision
The following table describes the way Time Precision is formatted in DML components when used in Business Documents and DML instructions.
.s |
The fractions of sections (s) specifies the precision. It is a digit or it could be the letter s to specify the default precision which is 3. While reading, the fractions of seconds are not required and at most, s digits are accepted. |
With 10:32:25.345400000, 4 means 3454.
With 10:32:25.345400000, .s means 345.
Formatting 10:32:25.345400000, .ss writes 225.34.
Reading 25, .ss.2, is okay.
Reading 25.1, .ss.2, is okay.
Reading 25.123, .ss.2, raises an error.
|
When it is not specified, the default fraction of seconds is 0.
Separators
The following table describes the way Separators are formatted in DML components when used in Business Documents and DML instructions.
- |
Minus |
Formatting 10/21/2011 with MM-DD-YY writes 10-21-11. |
/ |
Slash |
Formatting 10/21/2011 with MM//DD//YY writes 10//21//11. |
, |
Comma |
Reading 10,21,2011 with MM,DD,YY returns 10/21/11. |
; |
Semi-colon |
Reading 10;21;2011 with MM;DD;YY returns 10/21/11. |
: |
Colon |
Reading 10,21,2011 with MM,DD,YY returns 10/21/11. |
. |
Dot (period) (if it is not followed by a digit or an s, see Time precision.) |
Formatting 10/21/2010 with M.D.Y writes 10.21.10. |
T |
Uppercase t |
Reading 2010,10,21T01:33 with YYYY/MM/DDThh:mm returns 10/21/10 01 hours 33 minutes. |
<blank> |
space |
Formatting 10,21,2010 with M D Y gives 10/21/10. |
'text' |
Free text can be introduced in the date format between single quotes. |
Formatting 10,21,2010 08:03:20 with CCYY MM DD 'at' hh'H' mm'mn' ss's' returns 2010 21 10 at 08H 03mn 20s. |
If characters other than the reserved characters are entered into the date format, they are ignored unless they are placed in between singlbe quotation marks.
For compatibility with existing Business Documents, some date formats are predefined. These formats are predefined because they do not match any of the previously defined documentation.
Cobol |
CYYMMDD |
cYYMMDD |
Database
Generic
|
YYYYMMDDhhmmsshhmm |
YYYYMMDDhhmmssuhum |
IDocV4
Swift Fin User
TRADACOMS
|
HHMMSS |
hhmmss |
Swift Fin User |
HHMM |
hhmm |
Variable Size versus Fixed Size
When an input string is converted into an internal date, the input string maybe shorter than the date pattern. But when you use the DML function convertToD, the string parameter should match the date pattern. For example:
- 1823 with pattern hhmmss is accepted and returns 18h23m0s.
- 182312 with pattern hhmmssxx is accepted and returns 18h23m12s.