Function Examples

The following examples demonstrate how to use functions to calculate various dates.

You can define variables as shortcuts for functions that you use frequently. See the Variables with Functions topic for more information.

Yesterday's Date

For use by another function: @DateAdd(,-1,"day")

To insert the date using a specific format: @now("MMMM d, yyyy",-1,"day")

Start/End of Week

Show the date of the first and last days of the week containing the current date, treating Monday as the first day of week and Friday as the last day:

Show the date of the first and last days of the week that yesterday was part of, treating Monday as the first day of the week and Sunday as the last day.

We first use DateAdd to get yesterday's date, then find out what week it was in:

Start/End of Month

First day of current month: @StartOfMonth(, "yyyy-MM-dd")

Last day of current month: @EndOfMonth(, "yyyy-MM-dd")

The 15th of the Current Month

Get a date/time representing 8:15 AM on the 15th day of the current month: @AdjustDate(,,,15,8,15,0)

The first comma skips the optional targetDate argument, telling the function to use the current date/time. The next two commas skip the year and month arguments, telling the function to use the current year and month. The next four arguments tell the function to use the 15th day of the month, the eighth hour, 15th minute, and 0 seconds.

Related Concepts

Variables and Functions Overview

Related Topics

Variables with Functions

Reference

Function Reference

Date/Time Formats