-
Notifications
You must be signed in to change notification settings - Fork 0
pts expression editor dates
Strings representing dates can be manipulated with + and - just like numbers, and have a few functions to help work with them. Dates are seen internally as strings, and should be enclosed in quotes when trying to use literal dates; they can be given in your local / national format. The following operators are supported:
- date + count --> date string representing date + count days
- date - count --> date string representing date - count days
- date1 - date2 --> integer representing elapsed days (can be negative if date2 is a later date)
Note that when using standard operators, the operation always uses days as the time unit. To use other time units, you must use the supplied functions.
date_add( date, count[, unit_string] )
This adds the specified count of time units to the given date, and returns a new date.
date_subtract( date, count[, unit_string] )
This subtracts the specified count of time units from the given date, and returns a new date.
date_subtract( date1, date2[, unit_string] )
This subtracts the specified date from the first, and returns the elapsed time in the specified units. The result is always the count of whole units that have elapsed. So if you specify dates 20 days apart and ask for months, no whole months have elapsed and so 0 will be returned.
format_date( date, format_string )
This reformats the date string into the specified format for friendlier presentation. format_string can be #SHORTDATE, #LONGDATE, #CUSTOMDATE[date_format] just as they are for formatting dates with format specifiers. The hashes are optional here; for CUSTOMDATE you can simply supply the format such as "%Y-%m-%d".
To make it easier to select date formats for the second parameter of format_date(), you can apply formatting whenever you are inside speech - as long as you have an odd number of double quotes to the left of the cursor position the format can be inserted / updated as if the speech mark on the left were a variable. For example, if you type
format_date($Today, "
(note the trailing double quote) you can now select a date format and click Apply. It will be inserted at the cursor position, right after the quote. Placing the cursor anywhere within that format string will reflect the current format and allow you to change it, just like it does for a variable suffix.
date_part( date, units_string )
This returns an integer representing just the portion of the date you request.
make_date( year, month, day[, hour, minute, second] )
This returns a date string built from the parts you supply. Month is 1 - 12, day is 1 - 31.
- Unless otherwise specified, any date strings are returned in Access' timestamp format; use format_date() to change to a more familiar style.
- units_string is "Y", "M", "D" for years / months / days or the relevant portion of a date, or "h", "m", "s" for hours / minutes / seconds or the relevant portion of a date. Where supported, if you omit the unit string (or supply an unrecognised one), it is assumed to be "D" for days.
Copyright © 2002 - 2025 by Andrew Truckle. All Rights Reserved.
- Using Public Talks
- Main Application Menu
-
Database Ribbon Panel
- Assignments Editor
- Backup Database
- Check Talk Exchange
- Compact Database
- Convert Database
- Create Unassigned Date Entries
- Database Security
- Maintain Databases
- Purge Database
- Rearrange Dates
- Restore Database
- Help Ribbon Panel
-
Home Ribbon Panel
- Create a Report
-
Manage Custom Reports
- Editing Scripts
- Content Ribbon Panel
- System Ribbon Panel
- Script Command Syntax
-
Tutorials
- Using The Script Editor
-
How To Write Scripts
- Module 1 - The Basics
- Module 2 - Hello, World!
- Module 3 - Multiple Text Blocks
- Module 4 - It's A Date, Then
- Module 5 - Oh, I'm Blushing!
- Module 6 - It is a Rainbow!
- Module 7 - The Font Of All Knowledge
- Module 8 - Queue To The Right
- Module 9 - Memory Like An Elephant
- Module 10 - May I Squeeze In There?
- Module 11 - Move Over, Please
- Module 12 - You Move Over Here
- Module 13 - Is My Back A Funny Colour?
- Module 14 - I'm Going Loopy Here!
- Module 15 - Fields Of Golden... Text
- Module 16 - Man, That Looks Weird
- Module 17 - Inner Peace, Inner Loop
- Advanced Script Features
- Quick Access Toolbar
- Settings Ribbon Panel
- Tools Ribbon Panel
- Revision History
- Contact Information