The dateStart()
function returns the start date from a date range. It accepts a single date argument.
dateStart(date)
date.dateStart()
Code language: JavaScript (javascript)
dateStart()
is useful for obtaining the start date from a Date property which contains a date range.
When you pass a single date as the argument – i.e. from a Created Time/Last Edited Time property, or a timestamp – dateStart()
simply returns that date.
Example Formula
/* Assume a property "Date" exists, with a row value of June 23, 2022 → June 27, 2022 */
dateStart(prop("Date")) /* Output: June 23, 2022 */
Code language: JavaScript (javascript)
Date Math within dateStart() and dateEnd()
It’s useful to note that date math functions like dateAdd and dateSubtract return a date object that does not contain a date range – even if their argument does include one.
When these functions are passed a date object that includes a range, they only use a start date.
For this reason, the following two formulas will return the exact same date:
/* Assume a property "Date" exists, with a row value of June 23, 2022 → June 27, 2022 */
start(dateAdd(prop("Date"),30,"days")) /* Output: July 23, 2022 */
end(dateAdd(prop("Date"),30,"days")) /* Output: July 23, 2022 */
Code language: JavaScript (javascript)
Therefore, you must use the dateEnd function within your date math function if you wish to operate on the end date in a date range:
/* Assume a property "Date" exists, with a row value of June 23, 2022 → June 27, 2022 */
dateAdd(dateEnd(prop("Date")), 30, "days") /* Output: July 27, 2022 */
Code language: JavaScript (javascript)
Example Database
The example database below counts the number of days in a date range.
View and Duplicate Database
“Days” Property Formula
dateBetween(
dateEnd(
prop("Date Range")
),
dateStart(
prop("Date Range")
),
"days"
)
Code language: JavaScript (javascript)
This example formula uses dateStart()
and dateEnd to pass beginning and ending arguments to the dateBetween function.
By specifying “days” as the third argument, we get the number of days in the date range.