Guides

Formatting Dates

Dates play a pivotal role in document creation, and presenting them in a clear and standardized format is essential for effective communication. Whether you're preparing reports, invoices, or any other document, the way dates are displayed can significantly impact readability and professionalism.

In this guide, we will delve into the art of date formatting using Eledo, a powerful platform that employs the DATE function with standard Java date formats.

Understanding DATE function

The DATE function, with its two parameters, empowers users to transform raw date values into well-structured and visually appealing representations. It can be seamlessly integrated into any data expression field in your template.

DATE(value, date_format)
  • value - The input date value.
  • date_format - The desired format for the output date.

Input Date Value

Source date values can be extracted from the template's Input Fields, where the input field should be of Date type. Alternatively, you can use other data expressions to obtain a TODAY() value or calculate a Date value from different input fields using the TO_DATE() function to parse dates from various formats.

Date Format

Case sensitive pattern defines the output format of the date.

Basic Date Formatting

The case-sensitive pattern defines the output format of the date. Here are some basic examples:

Format an item.date input field with "dd MM yyyy" format:

DATE(item.date, "dd MM yyyy")

Print today's date in "yyyy-MM-dd" format:

DATE(TODAY(), "yyyy-MM-dd")

Overview of Java Date Format

Date Format specifies the output format of the Date value. It consists of case sensitive letters which represents parts of the date in various formatting options. Amount of letters is also important as it results in different date output value.

LetterDate or Time componentExamples
yYear2019 (yyyy), 19 (yy)
MMonth in yearJanuary (MMMM), Jan (MMM), 01 (MM)
wWeek in year23 (w)
WWeek in month2 (W)
DDay in year156 (D)
dDay in month02 (dd), 2 (d)
FDay of week in month5 (F)
EDay name in the weekFriday (EEEE), Fri (EEE)
uDay number of week where 1 represents Monday, 2 Tuesday and so on7 (u)
aAM or PM markerAM (a)
HHour in day (0-23)21 (H), 03 (HH)
hHour in day (1-12)11 (h), 04 (hh)
kHour in day (1-24)24 (k), 05 (kk)
KHour in day (0-11)0 (K), 01 (KK)
mMinute in the hour5 (m), 05 (mm)
sSecond in the minute7 (s), 07 (ss)
SMilliseconds in the minute584 (SSS)
zTimezonePacific Standard Time; PST; GMT-08:00
ZTimezone offset in hours (RFC pattern)-0800
XTimezone offset in ISO format-08; -0800; -08:00

Examples of Java date formats

  • "yyyy-MM-dd" - 2023-02-25
  • "dd MMMM yyyy" - 25 February 2023
  • "MM/dd/yyyy" - 02/25/2023
  • "dd/MM/yyyy HH:mm:ss" - 25/02/2023 13:30:00
  • "E, dd MMM yyyy HH:mm:ss z" - Sat, 25 Feb 2023 13:30:00 CET

Date Timezone and Locale

Timezone and Locale significantly affect the date's output format. To ensure proper formatting, set the appropriate Timezone and Locale in your Eledo Template through the Settings menu of the Eledo template editor.

Conclusion

Mastering date formatting not only enhances the aesthetics of your documents but also ensures consistency and clarity, making it easier for your audience to interpret and act upon the information presented.


Was this article helpful?

Yes

No