Follow

Evaluating Dates

 
Table of Contents
  1. 1. Overview
  2. 2. Tags
  3. 3. Related

Overview

Several Logic Tags are used to evaluate date values and output results to the content.

Tags

Dates can be literal (defined within brackets [05/11/2011]), builtin (builtin.today - without preceding $), variable (set in the template %%set date1 = 05/10/2011%%), or Contact or Custom Data ($customDate).

 

Tag %%eval age DATE%%
Parameters DATE: Date Literal, Variable, Custom Data, or Contact Data
Output Output the number of years between today's date and the specified date.  This is useful for age, anniversary type calculations.
Example %%set dob = "12/31/1975"%%
%%eval age $dob%%
Results 35
   
Tag %%eval dateadd DATE INT%%
Parameters DATE: Date Literal, Variable, Custom Data, or Contact Data
INT: Integer Literal, Variable, Custom Data, or Contact Data
Output Output the date adding the integer to the days of the date to result in a new date.
Example %%set date2 = 05/11/2011%%
%%eval dateadd $date2 [11]%%
Results 5/22/2011
   
Tag %%eval daysbetween DATE1 DATE2%%
Parameters DATE: Date Literal, Variable, Custom Data, or Contact Data
Output Output the number of days between two dates.
Example %%set date1 = 05/21/2011%%
%%eval daysbetween $date1 [05/31/2011]%%
Results 10
   
Tag %%eval formatdate FORMAT builtin.sqldatetime%%
Parameters FORMAT: Set variable with defined format. Specific characters are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') To print a single quote, use "'". See the table below for description of each character purpose.
Output Output the result of applying a specified format to the current date.
Example %%set formatDate = "E, dd MMM yyyy HH:mm:ss Z"%%
%%eval formatdate $formatDate builtin.sqldatetime%%
Results Fri, 22 Jul 2011 10:56:26 -0700
Example %%set formatDate = "MM/dd/yyyy hh:mm:ss zzz"%%
%%eval formatdate $formatDate builtin.sqldatetime%%
Results 07/22/2011 10:56:26 PDT
Example %%set formatDate = "EEEE, MMMM 'the' dd 'of' yyyy 'at' hh:mm a"%%
%%eval formatdate $formatDate builtin.sqldatetime%%
Results Friday, July the 22 of 2011 at 10:56 AM
Example %%set formatDate = "MM/dd/yyyy"%%

%%set newdate = {{eval dateadd builtin.today [10]}}%%

%%eval formatdate $formatDate $newdate%%

Results 08/01/2011

 

Letter Component Type Example
G Era designator Text G = AD
y Year Year yyyy = 2011; yy = 11
Y Week year Year YYYY = 2011; YY = 11
M Month in year Month MMMM = July; MMM = Jul; MM = 07; M = 7
w Week in year Number w = 30
W Week in month Number W = 4
D Day in year Number D = 203
d Day in month Number dd = 07; d = 7
F Day of week in month Number FF = 04; F = 4
E Day name in week Text EEEE = Friday; E = Fri
u Day number of week (1 = Monday, ..., 7 = Sunday) Number u = 1
a Am/pm marker Text a = PM
H Hour in day (0-23) Number H = 0; HH = 00
k Hour in day (1-24) Number k = 1; kk = 01
K Hour in am/pm (0-11) Number K = 0; KK = 00
h Hour in am/pm (1-12) Number h = 1; hh = 01
m Minute in hour Number m = 0; mm = 00
s Second in minute Number s = 0; ss = 00
S Millisecond Number S = 0; SSS = 000
z Time zone General time zone zzzz = Pacific Daylight Time; z = PDT
Z Time zone RFC 822 time zone Z = -0700; ZZ = -07
X Time zone ISO 8601 time zone X = -07; XX = -0700; XXX = -07:00
 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk