Skip to main content

How to personalize document generation using expressions

Docu Merge supports expressions which will help you customize and generate dynamic documents from the Template. The syntax for the expression is of the form {{ <some value> }}. It supports two types of expressions, namely static expression and dynamic expression.

Static Expression

The static expressions are predefined expressions available to each Google Sheet. List of supported static expressions and their meaning is given below.

List of Supported Static Expressions And their meaning:

  • {{ Unique Id }}: This expression generates a new unique id (UUID) ,every time it is used.
  • {{ DATE }}: Generates a date in the format MM-dd-yyyy. Example :11-13-2023
  • {{ DATE UK }}: Generates a date in the format dd-MM-yyyy. Example :23-11-2023
  • {{ DATE JP }}: Generates a date in the format yyyy-MM-dd. Example :2023-11-23
  • {{ FULL DATE }}: Generates a date in the format MMMM d, yyyy hh:mm:ss a . Example: December 5, 2023 02:08:55 PM
  • {{ DATE PATTERN }}: This can be used to generate any pattern you want .Please check section Custom Date Patterns.
  • {{ Time }}: Generates current time time in the format hh:mm a .Example: 2:08 PM
  • {{ Year }}: Generates Current Year in the format yyyy .Example: 2024
  • {{ Spreadsheet Name }}: Generates the Current Spreadsheet Name .
  • {{ Spreadsheet Id }}: Generates the Current Spreadsheet Id .
  • {{ Sheet Name }}: Generates the Active Sheet Name in the Active Spreadsheet .
  • {{ Sheet Id }}: Generates the Active Sheet Id in the Active Spreadsheet .

Dealing with Time zones

All the Date and Time expressions use the Time zone of the Google Sheet . By default, Google Sheets uses the time zone setting of your Google account.

Change Google sheet Time zone

To change the default timezone of your Google Sheet, follow these steps:

  • Open your Google Sheet from Google Drive.
  • Go to the File menu and select Settings.
  • In the Time zone section, choose your preferred timezone.
  • Click Save to apply the changes.

Supported Custom Date Patterns

Using this expression you can formulate Date in any pattern you want if the existing predefined patterns do not fullfill your requirement.

Syntax: {{ DATE PATTERN , <Custom Pattern Goes Here> }}

Pattern Letters and their Meaning

LetterDate or Time ComponentExample Output
GEra designatorAD
yYear1996; 96
YWeek year2009; 09
MMonth in year (context-sensitive)July; Jul; 07
LMonth in year (standalone form)July; Jul; 07
wWeek in year27
WWeek in month2
DDay in year189
dDay in month10
FDay of week in month2
EDay name in weekTuesday; Tue
uDay number of week1 (1 = Monday, ..., 7 = Sunday)
aAm/pm markerPM
HHour in day (0-23)0
kHour in day (1-24)24
KHour in am/pm (0-11)0
hHour in am/pm (1-12)12
mMinute in hour30
sSecond in minute55
SMillisecond978
zTime zone (General time zone)Pacific Standard Time; PST; GMT-08:00
ZTime zone (RFC 822)-0800
XTime zone (ISO 8601)-08; -0800; -08:00

Pattern Letters in the above table can be combined to generate various date patterns .See some examples below on how they can be used.

Examples:

Example OutputPattern
Tuesday, 5 December 2023 ADEEEE, d MMMM yyyy G
2023-12-05 14:08:55yyyy-MM-dd HH:mm:ss
12/5/23, 2:08 PMMM/dd/yy, h:mm a
December 5, 2023, 02:08:55 PMMMMM d, yyyy, hh:mm:ss a
05-Dec-2023 14:08dd-MMM-yyyy HH:mm
Tue, 5 Dec 23EEE, d MMM yy
2023 W49 D2YYYY 'W'ww 'D'd
14:08:55 PSTHH:mm:ss z
2:08 PM Pacific Standard Timeh:mm a zzzz
2023-12-05T14:08:55-08:00yyyy-MM-dd'T'HH:mm:ssXXX
12/05/2023 14:08:55 GMT-08:00MM/dd/yyyy HH:mm:ss Z
2023-339 (Day of the Year)yyyy-DDD
5th day of December, 2023d'th day of' MMMM, yyyy
Hour 2 of the 24-hour day, Minute 8'Hour' H 'of the 24-hour day, Minute' m
Tuesday, 5th December, 2:08 PM ADEEEE, d'th' MMMM, h:mm a G
ISO DateTime: 2023-12-05T14:08:55.123Zyyyy-MM-dd'T'HH:mm:ss.SSS'Z'

Dynamic Expression

The firs row in your Google sheet must contain user friendly names in each cell that can be used as dynamic expression. All subsequent rows will be processed and for each row the corresponding value to the first cell will be used to replace the expression.