Table of Contents

Formulas - Date

Marco de Vita Updated by Marco de Vita

If this is your first time using Formulas, please check our Getting Started guide here and our crash course here

Use the Date Formulas if you need to include the date and/or time to your chatbot, calculate delivery dates or show the date in a different format for your customers located in different regions.

Read this article for some practical examples of how to use all the different Date Formulas available within Landbot.

Formulas available

  • AddDays
  • AddMonths
  • AddYears
  • Now
  • Today
  • ToDate

AddDays

Add 3 days to the specified date 2020/01/01

AddDays(@my_date,3)

AddMonths

Add 4 months to the specified date 2020/01/01
AddMonths(@my_date,4)

AddYears

Add 2 years to the specified date 2020/01/01
AddDaysAddYears(@my_date,2)

Now

Get the current timestamp (date and hours) for a specific TimeZone

Check this link to see the supported values (TZ database name column).

Now("Africa/Abidjan")

Get Date (YYYY-MM-DD format) and Time (in HH:MM:ss)

GetValue(Split(Now("Europe/Madrid"),"."),0)

Get Date in YYYY-MM-DD

GetValue(Split(GetValue(Split(Now("Europe/Madrid"),"."),0)," "),0)
Get Time in HH:MM:ss

GetValue(Split(GetValue(Split(Now("Europe/Madrid"),"."),0)," "),1)

Get Date in DD-MM-YYYY format

In this case, we need to extract and store every element separately and join them after with a Set Variable block:

To get the variable @day:

GetValue(Split(GetValue(Split(GetValue(Split(Now("Europe/Madrid"),"."),0)," "),0),"-"),2)

To get the variable @month:

GetValue(Split(GetValue(Split(GetValue(Split(Now("Europe/Madrid"),"."),0)," "),0),"-"),1)

To get the variable @year:

GetValue(Split(GetValue(Split(GetValue(Split(Now("Europe/Madrid"),"."),0)," "),0),"-"),0)

And finally joining those variables using a Set Variable block:

Get Date (DD-MM-YYYY format) and Time (in HH:MM:ss)

If you want to add the time also, will be the same path as before (Get Date (DD-MM-YYYY format), but this time we will add a fourth formula, and add it to the Set Variable block

GetValue(Split(GetValue(Split(Now("Europe/Madrid"),"."),0)," "),1)

And the Set Variable block:

Today

Get current date
Today()

To add days to today's date, and then separate year, month and day into different variables in order to configure the desired date format use the following template

ToDate

Convert date to a format like this 2020-12-20

ToDate(@dates,"%Y-%m-%d")

How did we do?

Formulas - Regex

Formulas - String

Contact