getToday
This function returns today's date in ISO format (YYYY-MM-DD). It's a convenient way to get the current date for assignments, comparisons, or display purposes.
Syntax
app.getToday()
Parameters
This function does not take any parameters.
Return Value
Returns a String containing today's date in ISO format (YYYY-MM-DD).
Examples
Example 1: Set a date field to today's date:
// Set the invoice date to today
app.setFieldValue("invoiceDate", app.getToday());
Example 2: Compare a date field with today's date:
// Check if due date has passed
const dueDate = app.getFieldValue("dueDate");
const today = app.getToday();
if (dueDate < today) {
app.showMessage({
title: "Payment Overdue",
content: "The payment due date has passed!",
type: "warning"
});
}
Example 3: Creating a date range from today:
// Set a date range for a report - today plus 30 days
const today = app.getToday();
const futureDate = app.getDate(new Date(new Date().setDate(new Date().getDate() + 30)));
app.setFieldValue("reportStartDate", today);
app.setFieldValue("reportEndDate", futureDate);
Example 4: Using today's date in a database query:
// Find all orders created today
const ordersToday = app.sqlRead("GetOrdersByDate", {
orderDate: app.getToday()
});
// Display the count of today's orders
app.setFieldValue("ordersTodayCount", ordersToday.length);
Related Functions
getDate()
- For formatting any date object in ISO formatgetCalcDate()
- For getting a date as a numeric value (days since epoch)getCalcDateTime()
- For getting a date and time as a numeric valuegetEndOfMonth()
- For getting the last day of a month
Notes
- The date is returned in ISO format (YYYY-MM-DD), which is suitable for database operations and comparisons
- The function uses the local timezone of the client to determine "today"
- For time-sensitive operations that need to account for different time zones, consider using server-side date functions
- This function returns only the date part without time information
- The returned string can be directly used in date comparisons since ISO format strings compare correctly