Recently, I got an opportunity to work with the Now, Today, IsToday, and UTCNow functions to get the current date and time, current date without time, date format, etc.
In this Power Apps tutorial, I will explore all about PowerApps now() format, PowerApps now() timezone, Power Apps today format, Power Apps today date without time, and Power Apps get current year with different scenarios.
Also, we will work with Power Apps current date and Power Apps if date is less than today.
Power Apps Now()
The Power Apps Now() function gets the current date and time as a date/time value. This function works with the current user’s local time.
Power Apps Now Function Syntax:
Now()
Power Apps Now() Format
To change the current date and time format to “mm/dd/yyyy” format using the Now() function, follow the code below. [you can write the code on Label’s Text property]
Text = Text(
Now(),
"mm/dd/yyyy hh:mm:ss"
)
Power Apps Now() Timezone
Suppose you want to convert the UTC time returned by Now() to a specific timezone, such as “Eastern Standard Time (EST)” in Power Apps.
To achieve it, you can follow the below to set the Text label’s Text property.
Text = Text(
Now() + Time(
5,
0,
0
),
"[$-en-US]yyyy/mm/dd hh:mm:ss AM/PM"
)
Power Apps Now() Add Dates
In this example, if you want to add 15 days to the current date, you can use the code below.
Text = Text(
DateAdd(
Now(),
15
),
"mm/dd/yyyy hh:mm:ss"
)
Power Apps Today Function
Power Apps IsToday function helps to test whether a date/time value is between midnight today and midnight tomorrow. The result of this function returns a Boolean (true or false) value. Also, this function works with the local time of the current user.
Power Apps Today Function Syntax:
Today()
Power Apps Today Format
To change the current date and time format using the Today() function, follow the code below.
Text = Text(
Today(),
"dd/mm/yyyy hh:mm:ss"
)
Note:
The Power Apps Today Function is helps to get the current date only, leaving the time portion as midnight, and displays it as a string.
Output:
Power Apps Today Date Without Time
In this example, I will show you how to get the current or today’s date without time using the Today() function.
For that, you can set the below code to the DatePicker’s DefaultDate property, as shown below.
DefaultDate = Today()
Note:
Whenever you add the date picker control to the Power Apps, it will always display the current date as a Default date without time.
Power Apps If Date is Less Than Today
Now, I will show you how to work with the Power Apps if the date is less than today using a simple example.
Example:
I have a SharePoint list named “Product Details” and this list contains the below fields.
Column Name | Data Type |
Product Name | It is a default single line of text column |
Manufacturer | Choice |
Price | Currency |
Quantity | Number |
Purchase Date | Date and time |
In Power Apps, there is a Data table control having the SharePoint Online list records. Now, I would like to filter and display each record from the SharePoint list based on the date [If Date is Less Than Today].
To work around this, you can use the code to set the data table’s Items property.
Items = Filter(
'Product Details',
PurchaseDate < Today()
)
Where,
- ‘Product Details’ = SharePoint Online list
- PurchaseDate = SharePoint list date and time field
Have a look at the below screenshot for the output:
Power Apps IsToday Function
Power Apps IsToday function helps to test whether a date/time value is between midnight today and midnight tomorrow. The result of this function returns a Boolean (true or false) value. Also, this function works with the local time of the current user.
Power Apps IsToday Function Syntax:
IsToday(DateTime)
Where,
DateTime = This is required. Specify a date/time value to test
Power Apps IsToday Function Example
Suppose you want to check if the current date is equal to Today; the Text label displays the text “This date is today!” Otherwise, if the date is not today’s date, the function returns the text “This date is not today.”
To do so, follow the below code.
Text = If(
IsToday(4 / 16 / 2024),
"This date is today!",
"This date is not today"
)
Power Apps UTCNow Function
Note:
UTCNow, UTCToday, and IsUTCToday are only available in Microsoft Dataverse for Teams formula columns, and only for time-independent fields and values.
However, you can use the DatePicker’s Date time zone as UTC, as shown below.
Power Apps Current Time
In this example, I will show you how to get the current time [Without Date] using Timer control. To achieve it, follow the below steps.
1. On The Power Apps Screen, insert a Timer control, set its Duration property to 1000, and make the Repeat property true [The timer will run for one second, automatically start over, and continue that pattern].
2. Next, set the Timer control’s OnTimerEnd property to the code below.
OnTimerEnd = Set(CurrentTime, Now())
Where,
- CurrentTime = Power Apps Variable Name
3. Now, insert a Text label and set its Text property as:
Text = Text(
CurrentTime,
DateTimeFormat.LongTime24
)
4. Save and Preview the app. Whenever the user clicks or taps the Timer control, The text label continually shows the current time, as shown below.
Output:
This is how we can work with Power Apps current time without a date.
Power Apps Get Current Year
If you want to get the current year in the Power Apps app, you can follow the code below.
Text = "Current Year: " & Year(Now())
Power Apps Get Current Month
Similarly, if you want to get the current month in Power Apps, you can follow the code mentioned below.
Text = "Current Month: " & Text(
Today(),
"mmmm"
)
This Power Apps tutorial teaches detailed information about the Power Apps Now, Today, IsToday, and UTCNow Functions with different examples.
Also, we learned how to work with PowerApps today date without time, get Power Apps current date, Power Apps get current year, etc.
Moreover, you may like:
- Power Apps First, FirstN, Last, and LastN Functions
- Power Apps PDF Viewer Control
- Power Apps Remove First Character from String
- Navigate Function in Power Apps
- PowerApps Replace Character in String
- Power Apps Length Of String
- Power Apps Rating Control
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com