The Today function in PowerApps returns the current date without the time component. This function is useful for any scenario where you need to reference the current date, such as setting default values, filtering records by date, or performing date calculations.
PowerApps – Today() function Syntax
The Today function does not take any arguments.
Notes:
- Time Zones: Be aware of the user's time zone, as Today returns the current date based on the local time zone of the device running the app.
- Date Calculations: When performing date calculations, ensure that the time component is handled correctly if you are also working with Now or other date-time functions.
PowerApps – Display current date
To display the current date in a label:
Set the Text property of a label to Today() to display the current date.
To format the current date in a specific way, use the Text function with the Today function:
Text(Today(), "[$-en-US]dddd, mmmm dd, yyyy")
This formats the current date as "Tuesday, May 21, 2024" (depending on the actual current date).
PowerApps - Set a Default Date in a Date Picker
To set the default date of a date picker to today's date:
DatePicker1.DefaultDate = Today()
PowerApps – Filter Records by current Date
Suppose you have a table named Tasks with a DueDate column, and you want to filter tasks that are due today:
Filter(Tasks, DueDate = Today())
This filters the Tasks table to include only those tasks due today.
PowerApps - Calculate Days Until a specific date
If you want to calculate the number of days remaining until a specific deadline, you can use the DateDiff function in combination with Today:
DateDiff(Today(), DeadlineDate, Days)
This calculates the number of days between today and the DeadlineDate.