Formatting Dates

Copy and paste these to format and calculate your dates.  

Just replace DateVariable with your own variable.

Dates can be in any format you like, using your desired format after format.  Example: the format for inserting just the year for a date is {{ format_date(date, format='yyyy') }}.

Formatting Dates

Default Date (January 10, 2020):

{{ DateVariable }}

Today's Date (inserts today's date):

{{ format_date(today()) }}

To format today's date using any of the methods below, you can omit the ""format"" portion, like this: {{ format_date(today(), 'full') }}

Full Date (Saturday, January 10, 2020):

{{ format_date(DateVariable, format='full') }}

mm/dd/yy (1/10/20):

{{ format_date(DateVariable, format='short') }}

mm/dd/yyyy (01/01/2020):

{{ format_date(DateVariable, format='MM/dd/yyyy') }}

m/dd/yyyy (1/01/2020):

{{ format_date(DateVariable, format='M/dd/yyyy') }}

dd/mm/yyyy (10/01/2020):

{{ format_date(DateVariable, format='dd/MM/yyyy') }}

Month ___, Year (January___, 2020):

{{ format_date(DateVariable, format='MMMM ____, yyyy') }}

mm/dd/yyyy (01012019):

{{ format_date(DateVariable, format='MMddyyyy') }}

Today's Month ___, Year (inserts today's Month ___, Year):

{{ format_date(DateVariable, format='MMMM ____, yyyy') }}

The date day of Month 2020 (the 10th day of January 2020):

The {{ ordinal_number(, use_word=False) }} day of {{ format_date(DateVariable, format ='MMMM yyyy') }}

Shortened Month (30Nov20):

{{ format_date(DateVariable, format='ddMMMyy') }}

Calculating Dates

Selecting the Next Business Day

{{ next_business_day(DateVariable) }}

Selecting the Prior Business Day

{{ prior_business_day(DateVariable) }}

Calculate the number of days/years between a date and today (useful for calculating age from a birthday)

{{ (date_difference(starting=DateVariable).years|int) }}

Calculate the number of days/years between two dates  

{{ (date_difference(starting=StartingDateVariable, ending=EndingDateVariable).years|int) }}

Add or subtract days or years to a date (useful for statutes of limitation / notice periods)

{{ format_date( (DateVariable) + date_interval(years=2) ) }}

  • Instead of years, you can use years, months, days, weeks or current_datetime()
  • Instead of +, you can use - to subtract dates

Calculate the number of months between two dates:

{{ (relative_date_difference(starting=DateVariable, ending=SecondDateVariable).months) }}

Display the last day of the month (e.g., If your DateVariable is April 15, it would show the date April 30)

{{ last_day_of_month(DateVariable) }}

If you want to separate out just the last day of the month (e.g., 30), you can do this:

{{ format_date(last_day_of_month(DateVariable), format='dd') }}

Formatting Text as a Date

The strftime function is used to turn a variable that is not a date-type into a date, so long as it is properly formatted. This is most commonly used when you are importing data from another system. For example, this can be used to turn Clio fields from text to date variables.

{{ as_datetime(variable).strftime(""%B %d, %Y"") }}

Use %-d instead of %d to show a single digit date (e.g., January 3 instead of January 03)."