Logo Text Blaze

  • Docs
  • Community
  • Business
  • Documentation

    No search results

    Text Blaze

    Loading...

    Data Blaze

    Loading...

    Community Forums

    Loading...
  • Products
    • Text Blaze
      Snippets and templates
    • AI Blaze
      AI writing and editing
    • Data Blaze
      Tables and sheets
    Downloads
    • Add to Chrome
    • Windows app
    • MacOS app
  • By function
    • Support & operations
    • Sales
    • Healthcare
    • Education
    • Recruiting
    • Marketing
    Business
    • For teams
  • Resources
    • Documentation
    • Community forum
    • Gallery
    • Contact us
  • Pricing

Documentation

No search results

Text Blaze

Loading...

Data Blaze

Loading...

Community Forums

Loading...
Add to Chrome –  It's Free! Go to Dashboard ›
Docs > Guides
  • Guides
    • Quick Start
    • Sharing Snippet Folders
    • Dynamic Commands
    • Date and Time
    • Autopilot
    • Forms
    • Formulas
    • Rules & Validation
    • Tables in Snippets
    • Connect Other Apps
    • Tidying Whitespace
    • Lists
    • Read Data from Websites
    • Teams and Organizations
  • Tutorial Videos
  • Gallery
  • Frequently Asked Questions
  • Formula Reference
  • Dynamic Commands
    • Using Dynamic Commands
    • {=} (Formula Command)
    • {button}
    • {click}
    • {clipboard}
    • {cursor}
    • {error}
    • {formdate}
    • {formmenu}
    • {formparagraph}
    • {formtext}
    • {formtoggle}
    • {if}
    • {import}
    • {key}
    • {link}
    • {note}
    • {repeat}
    • {run}
    • {site}
    • {snippet}
    • {time}
    • {user}
    • {wait}
  • Connected Snippets
    • Connected Snippets Overview
    • {image}
    • {urlload}
    • {urlsend}
    • {dbselect}
    • {dbinsert}
    • {dbupdate}
    • {dbdelete}
  • Command Packs
    • Capitalize
    • Gmail
    • LinkedIn
    • Randomize

What's on this Page

  • Inserting today's date
  • Inserting the current time
  • Presenting dates and times in different formats
  • Shifting the date and time
    • Shifting to the beginning or end of a period
  • Manually selecting specific dates
  • Setting an anchor date
  • Advanced examples
    • Greeting based on the time of day
    • Calculate other dates based on a starting date
    • Calculate the difference between two dates
      • Ensuring the correct format for date functions
    • Calculate the date x weekdays from a selected date
    • Calculate the date of a day next week
    • Calculate someone's age based on their date of birth
Guides

Dynamically inserting dates and times

Quick Overview Video

Summary: You can add to your snippet today's date, the current time or any dates and times in the past or future such as tomorrow's date, the time 3 hours ago, the date of the first Monday of next month, and so on.

Inserting today's date

  1. When editing a snippet - click on the date menu
  2. Select the date format you'd like to use
  3. Try the snippet

Here's a sample snippet you can copy over to your dashboard.

Meeting notes with current date
Meeting notes: {time: MMMM Do YYYY}
_

Inserting the current time

  1. When editing a snippet - click on the time menu
  2. Select the time format you'd like to use
  3. Try the snippet

Here's an example:

Meeting notes with current time
{time: h:mm A} - Topic:
_

Presenting dates and times in different formats

You can present the dates and times in different ways. For example, July 4, 1776 at 7:03pm can be shown as (very partial list):

  • Thursday, July 4, 1776
  • 7/4/1776
  • 1776-07-04 at 7pm
  • Thursday
  • 19:03
  • And so on.

To change the way the time is presented:

  1. In the snippet editing window, click on the time or date command you added (the command "pill")
  2. Change the time/date format setting
  3. Try the snippet

Below is a snippet showing the current date and time in different formats:

Different date and time formats
{time: DD/MM/YYYY [at] HH:mm} {time: h:mm a [on] MMM-DD} {time: ddd, MMMM Do, YYYY} {time: [Quarter] Q [of the year] YYYY} {time: [Week] W [of the year] YYYY}
_

Note how it's possible to add custom text into the date and time formatting by placing that text [within brackets, like this], inside of the time command.

Try it out

  1. Create a new snippet and add a date or time command or copy the one above
  2. Try changing the format in which the date or time is presented

Below are some of the most commonly used date formats. You can find all the available formats here.

TokenOutput
Month
M1 2 ... 11 12
Mo1st 2nd ... 11th 12th
MM01 02 ... 11 12
MMMJan Feb ... Nov Dec
MMMMJanuary February ... November December
Day of Month
D1 2 ... 30 31
Do1st 2nd ... 30th 31st
DD01 02 ... 30 31
Day of Week
d0 1 ... 5 6
do0th 1st ... 5th 6th
ddSu Mo ... Fr Sa
dddSun Mon ... Fri Sat
ddddSunday Monday ... Friday Saturday
Year
YY70 71 ... 29 30
YYYY1970 1971 ... 2029 2030
AM/PM
AAM PM
aam pm
Hour
H0 1 ... 22 23
HH00 01 ... 22 23
h1 2 ... 11 12
hh01 02 ... 11 12
k1 2 ... 23 24
kk01 02 ... 23 24
Minute
m0 1 ... 58 59
mm00 01 ... 58 59
Second
s0 1 ... 58 59
ss00 01 ... 58 59

Shifting the date and time

But what if you want to insert yesterday's date? Or the time two hours from now? Move the date/time forward or backward using the shift setting.

There are two ways to shift the date command:

Option 1 - Shift an existing time command

  1. Click on the command you added (the command "pill")
  2. In the Shift setting, set the shift unit (Days, Weeks, Months, etc.)
  3. Set the shift value (1, 2, 5, 10, etc.)
  4. Try the snippet

Option 2 - insert a shifted time command

  1. Click on the shift menu
  2. Select the required shifted time
  3. Try the snippet

The example below shifts today's date forward by 1 day to insert tomorrow's date.

Tomorrow's date
Action items for tomorrow, {time: ddd, MMM Do, YYYY; shift=1D}
_

Try it out

  1. Create a new snippet and add a date or time command or copy the one above
  2. Try shifting the date or time using different Shift settings

Shifting to the beginning or end of a period

You can also shift the date to the beginning or end of a given period (e.g. week, month, quarter). In the example below, last quarter's number is dynamically presented along with the dates of the first and last days of the quarter.

Last quarter number, starting date and ending date
This is your statement for last quarter (Q{time: Q; shift=-1Q}), starting {time: MMMM DD, YYYY; shift=-1Q<Q} and ending {time: MMMM DD, YYYY; shift=-1Q>Q}
_

Try it out

  1. Create a new snippet and add a date or time command or copy the one above
  2. Try shifting the date to the end of the current week, month or quarter

Manually selecting specific dates

Date shifting, as described in the previous section, is used to shift dates by specific amounts.

If you need to select a specific date, the formdate command is more appropriate than the time command. When a formdate field is included in your snippet, you will be presented with a calendar date selector to choose a specific date.

formdate vs. time commands
Here's a simple time command showing today's date: {time: YYYY-MM-DD}

Here's the time command with the shift setting set to +3D: {time: YYYY-MM-DD; shift=+3D}

To manually select a date instead, consider using a formdate command: {formdate: YYYY-MM-DD}
_

Setting an anchor date

By default, the current date and time are used as the "anchor", but you can set any other date and time as the anchor. Do that by setting the At setting.

The example below sets the anchor to be July 4th 1776:

Day at a given date
The day on July 4, 1776 was {time: dddd; at=1776-07-04}
_

Advanced examples

Greeting based on the time of day

This snippet determines the greeting (Good morning, Good evening, etc.) based on the time in which it is inserted. It uses the H time format, which gives the current hour (0-24) and an {if} command to determine the greeting.

Note: The {if} command is a Pro feature, but you can test it on the free plan.

Time-based greeting
Good {if: {time: H} < 12}morning{elseif: {time: H} < 17}afternoon{else}evening{endif}
_

Calculate other dates based on a starting date

Using the "at" setting described here, snippets can automatically calculate other dates. This is useful in scenarios such as needing to lay out a timeline of events based on an initial date.

The snippet below demonstrates this by allowing you to select a date and then writing the date 91 days later. You'll notice that the date selection is done inside a note and therefore is not typed when the snippet is inserted. The date selection is using a Form Date command (Pro feature) and then sets it as the date "anchor" using the At setting, which is then shifted by 91 days.

The date in 91 days from a selected date
{note}(Internal only)Start date: {formdate: YYYY-MM-DD; name=start_date}{endnote: trim=yes}The item is due {time: dddd; shift=+91D; at={=start_date}}, {time: MM-DD-YYYY; shift=+91D; at={=start_date}}
_

The starting date can be used in multiple time commands within a single snippet to lay out a complete timeline as well.

Timeline snippet
Since your initial evaluation was on {formdate: YYYY-MM-DD; name=start_date}, here's the timeline with important milestones for your progress:

First check-in: {time: YYYY-MM-DD; at={=start_date}; shift=+1W}

Mid-way check-in: {time: YYYY-MM-DD; at={=start_date}; shift=+2W}

Last check-in: {time: YYYY-MM-DD; at={=start_date}; shift=+3W}

6 month follow-up appointment: {time: YYYY-MM-DD; at={=start_date}; shift=+6M}
_

Calculate the difference between two dates

This example is the corollary to the previous example, instead finding how many days are between two dates using the datetimediff function. In addition to finding the difference between two dates, there are several other date time functions available in Text Blaze.

In this example, we'll select two dates from Form Date fields to determine the difference between those dates. We'll also use an {if} command to take different actions depending on how far apart the dates are.

Calculating date difference
Select the first date: {formdate: YYYY-MM-DD; name=date1} Select the second date: {formdate: YYYY-MM-DD; name=date2; default={time: YYYY-MM-DD; shift=+1D}} {difference=datetimediff(date1, date2, "D"); trim=left}

Using datetimediff, I can determine that these two dates are {=difference} days apart.

{if: difference<0}The second date selected is prior to the first date selected{elseif: difference>0}The second date selected is after the first date selected{else}Both selected days are the same{endif}
_
The datetimediff function used in this snippet will compare the second date relative to the first date. That is, if the second date is later than the first, a positive number will be returned. If the second date is earlier than the first, a negative number will be returned.

Ensuring the correct format for date functions

Date functions like datetimediff and datetimeadd expect the dates to be formatted as YYYY-MM-DD. If you're using other formats for dates in your snippets, you can first use datetimeparse to format them as such.

Doing this allows you to present the date and/or time in one format in your snippet, but also use it for calculations in these functions.

Using datetimeparse
I want to display today's date as well as the date 1 week from today in the format of MMM, Do, YYYY in my snippet: Today: {today={time: MMM, Do, YYYY}}{=today}

1 week from today: {week={time: MMM, Do, YYYY; shift=+1W}}{=week}

But now I need to calculate the difference between those 2 dates. If I don't use datetimeparse first, I'll receive an error: {=datetimediff(today, week, "D")}

So I'll use datetimeparse on the two dates first, then datetimediff and now it'll work: {=datetimediff(datetimeparse(today, "MMM, Do, YYYY"), datetimeparse(week, "MMM, Do, YYYY"), "D")}
_

Calculate the date x weekdays from a selected date

Similarly, this snippet asks for a start date and the duration in weekdays and calculates the expected end date.

It uses the Form Date command to get the date and a Form Text command to get the duration in weekdays. It then anchors the date to the one selected in the Form Date and shifts it by the number of weekdays selected in the Form Text.

x weekdays from a selected date
We plan to start working on the project on{formdate: YYYY-MM-DD; name=start_date}. The expected duration of the project is {formtext: name=weekdays; default=5} weekdays. We expect to have the deliverables back to you by {time: dddd, YYYY-MM-DD; shift=+{=weekdays}D(skip=SAT, SUN); at={=start_date}; pattern=YYYY-MM-DD}
_

It's also possible to adjust a date using the datetimeadd function instead of the shift setting. This function will require that your input date be formatted as YYYY-MM-DD.

Using datetimeadd
Select an initial date: {formdate: YYYY-MM-DD; name=initial}

How many days do you want to add or subtract from this initial date? Enter a positive or negative number: {formtext: name=adjustment_period}

Here's the adjusted date using the datetimeadd function: {=datetimeadd(initial, {=adjustment_period}, "D")}
_

Calculate the date of a day next week

This snippet calculates the date of a given day next week.

It uses a drop-down menu (the Form Menu command) to capture the day and then uses a sophisticated shifting to a boundary, with the day set as the boundary.

The Pattern setting is used to tell Text Blaze what format is used for the "anchor" (The At setting).

Future date at a given day of the week
{note}Next meeting day: {formmenu: name=day; Monday; Tuesday; Wednesday; Thursday; Friday; Saturday; Sunday}{endnote: trim=right} Here's the agenda for our upcoming weekly staff meeting on {time: dddd, MMMM Do; shift=>{=upper({time: ddd; at={=day}; pattern=dddd})}}.
_

If you'd like to read more, check out the complete documentation page (video included): https://blaze.today/commands/time/

Calculate someone's age based on their date of birth

Pretty self-explanatory...

The X time format produces the current time in seconds (the number of seconds that have passed since 1 Jan 1970).

This snippet uses the Form Date command to capture the birthdate. Then it calculates the number of seconds currently and at the date of birth. The difference between the two is then converted to years using a formula.

Calculate age based on DOB
The patient was born: {formdate: YYYY-MM-DD; name=DOB}. Currently {=datetimediff(DOB, {time: YYYY-MM-DD}, "Y")} years old.
_

About

Plans and Pricing
Sharing Snippets
Text Blaze for Business
Forms
Autopilot
Dynamic Commands
Command Packs
Text Blaze for Windows
Text Blaze for macOS

Support

Get Started with Text Blaze
Contact Us
Documentation
Community Forum
Blog
Gallery
Engineering Blog

Solution for

Business
Customer Support
Recruiters
Education
Healthcare
Sales
Property Managers
AI

Other

Privacy Policy
Terms of Service
Open Source Licenses
Affiliate
© Blaze Today Inc