Working with dates and times, such as formatting dates according to time zone, is currently the most difficult challenge for Power Apps developers. In this Power Apps tutorial, we will discuss how to get current date in Power Apps.
To get the current date, we are going to use the different types of date and time functions such as Now(), Today(), etc.
Recently, I was working on a canvas app in Power Apps, where we need to display the current date.
To meet this requirement, the following steps are:
Get current date using Power Apps Today()
Under the Power Apps Date and time function, there is a function named Today(). That returns the current date.
The syntax for this function is:
Today()
Let’s build a blank canvas app and use this function to get the current date in Power Apps.
- Sign in the PowerApps with your Microsoft credential.
- Go to Create > Blank App > Canvas App.
- Give a name to the canvas app > Create.
Now the canvas app is ready. To display the current date within the Power Apps screen, add a Label control to the screen. Go to Insert > Input > Text label.
Insert the below expression on the label’s text property to display the current date.
Text = Today()
The above Power Apps screen is displaying the current date i.e., 2/7/2023. This is how to get the current date on the Power Apps screen.
Get the current date using Power Apps Now()
There is another function named Now() under the Power Apps date and time function that is used to return the current date with time.
The syntax for this function is:
Now()
Let’s use this function inside the Power Apps screen to display the current date with the time. To implement this, we are going to use the above Power Apps canvas app.
- Add a label control to the Power Apps screen.
- Insert the below expression on the label’s text property.
Text = Now()
The above Power Apps screen is displaying the current date with the time i.e., 2/7/2023 1:18 PM. This is how to get the current date with the time within the Power Apps.
Get the current date using Power Apps date picker control
Along with the data label control, we can use the Power Apps date picker control to get the current date.
By default, while using a Power Apps date picker control, it will display the current date as per the date time zone such as local or UTC.
Let’s use the Power Apps date picker control to display the current date, and the following steps are:
- On the above Power Apps screen, add a Date and time picker control. Go to Insert > Input > Date picker control.
- Once we add the date picker control to the screen, it will display the current date as default.
- On the above screen, it is displaying the current date based on the time zone i.e., Local. But, it allows setting the time zone to UTC format.
- Once we set the time zone to UTC, the current date will display in the UTC format as below. Select the above date picker control > DateTimeZone > UTC.
This is how to get the current date in Power Apps Date picker control.
Read How to filter SharePoint choice field within Power Apps?
How to check the current date in Power Apps?
Here, we will see whether the selected or inserted date is the current date or not in Power Apps. There is another function named IsToday() that determines whether a date/time value is between 12:00 a.m. today and 12:00 a.m. tomorrow. This function returns a Boolean value (true or false).
To work with this Power Apps function, we are going to use the above date picker control and the following steps are:
- On the above Power Apps screen, add a text label control and place it beside the date picker control.
- Insert the below expression on the label’s text property to check whether the selected date is the current date or not.
Text = IsToday(DatePicker1.SelectedDate)
Whether DatePicker1 is the name of the Power Apps date picker control.
As the selected date i.e., 2/7/2023 is the current date, it is displaying the result as true. Similarly, if you select another date, then it will display the result as False as below:
This is how to check the current date in Power Apps.
Conclusion
From this Power Apps tutorial, we learned how to get current date within the Power Apps using different functions and control. Such as:
- How to get the current date using Power Apps Today() function?
- How to get the current date and time using Power Apps Now() function?
- How to get the current date using the Power Apps date picker control?
- How to check the current date within the Power Apps?
You may like the following Power Apps tutorials:
- How to calculate sum of gallery items in Power Apps?
- How to set default value in Power Apps data card?
- get month name from date in Power Apps
- How to remove all items from a collection in PowerApps
- Power Apps collection filter
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.