LassoScript Utility
Basics Browse Detail

[Date]

Tag Link [Date] Category Date
Type Substitution Source Available No
Support Preferred Version 3.0
Change Unchanged Data Source Any
Output Type Date Security None
Implementation LCAPI Sets Lasso 8.5, Lasso 8.0, Lasso 7.0, Lasso 6.0, Lasso 5.0

Description

[Date] casts a date string as a Lasso date data type, constructs a date from parameters, or returns the current date/time when used without parameters.

Each part of a date can be specified using -Year, -Month, -Day, -Hour, -Minute, and -Second. However, these parameters should not be used in conjunction with a string parameter and -Format parameter.

To cast a date string as a Lasso date data type, the date string should either be in a Lasso date string format or should be in the format specified by the -Format keyword/value parameter. The following Lasso date string formats are recognized without the use of the -Format parameter.

mm/dd/yyyy
mm/dd/yyyy hh:mm
mm/dd/yyyy hh:mm:ss
mm/dd/yyyy hh:mm:ss GMT
yyyy-mm-dd
yyyy-mm-dd hh:mm:ss
yyyy-mm-dd hh:mm:ss GMT
yyyymmddhhmmss
yyyymmddThh:mm:ss
day, mon dd yyyy hh:mm:ss zone
day, mon dd hh:mm:ss zon yyyy

When used, the -Format parameter uses the following keyword/value parameters to indicate the format of the date string.

%D U.S. date format (mm/dd/yyyy).
%Q MySQL date format (yyyy-mm-dd).
%q MySQL timestamp format (yyyymmddhhmmss).
%r 12-hour time format (hh:mm:ss [AM/PM]).
%T 24-hour time format (hh:mm:ss).
%Y 4-digit year.
%y 2-digit year.
%m Month number (1=January, 12=December).
%B Full English month name (e.g. "January").
%b Abbreviated English month name (e.g. "Jan").
%d Day of month (1-31).
%w Day of week (1=Sunday, 7=Saturday).
%A Full English weekday name (e.g. "Wednesday").
%a Abbreviated English weekday name (e.g. "Wed").
%H 24-hour time hour (0-23).
%h 12-hour time hour (1-12).
%M Minute (0-59).
%S Second (0-59).
%p AM/PM for 12-hour time.
%G GMT time zone indicator.
%z Time zone offset in relation to GMT (e.g. -0800).
%% A percent sign.

By default, all input is assumed to be zero padded to two characters. For example, 02/03/2002.

A hyphen - between the % and the letter code instructs Lasso not to look for padding. For example, 2/3/2002

An underscore _ between the % and the letter instructs Lasso to to look for padding with spaces. For example, 2/ 3/2002.

Syntax

[Date]

[Date:'Base Date']

[Date:'Base Date', -Format='Date Format']

[Date: -Year=Year,
-Month=Month,
-Day=Day,
-Hour=Hour,
-Minute=Minute,
-Second=Second,
-DateGMT]

Parameters

Optional Parameters
Base Date An unnamed parameter will be interpreted as a date using the built-in formats or that specfied in the -Format parameter.
-Second Specifies the seconds of the day.
-Minute Specifies the minutes of the day.
-Hour Specifies the hour of the day.
-Month Specifies the month of the year.
-Day Specifies the day of the month.
-Year Specifies the year.
-DateGMT Specifies the input date is to be treated as GMT.
-Format Used in conjunction with a string parameter, specifies the format of date contained in that parameter.

Change Notes

The -DateFormat parameter in LDML 5.0 changed to -Format in LDML 6.0. The %q format was added in 7.0.3.

The three uses of the tag are mutually exclusive. Either the tag should be used as [Date] to fetch the current date, or with a string and optional -Format to cast a string to date, or with parameters for each part of the date. Mixing the different methods by specifying a string date and individual date parameters can cause unexpected errors.

Examples

To import a date field from MySQL:

Use the [Date] tag with an appropriate -DateFormat parameter. The format for MySQL dates is %Y-%m-%d %H:%M:%S. The following example imports a date from a field named Modified_Date.

The return value is the date formatted in Lasso date string format.

[Date: (Field: 'Modified_Date'), -Format='%Y-%m-%d %H:%M:%S']

3/4/2001 12:34:56