All Power Apps Date & Time Functions (With Examples)

All Power Apps Date & Time Functions (With Examples)

Working with dates & times is one of the biggest challenges in Power Apps. Dealing with date formats, time-zones and date manipulation is even hard for experienced Power Apps developers. In this article I will list all of the Power Apps date & time functions and show examples of how to use them.

Table Of Contents:

Current Date & Time
TODAY Function
NOW Function

Type Conversion Functions
DATE Function
TIME Function
DATEVALUE Function
TIMEVALUE Function
DATETIMEVALUE Function
TEXT Function

Date & Time Manipulation Functions
DATEADD Function
DATEDIFF Function
TIMEZONEOFFSET Function

Date & Time Parsing Functions
YEAR Function
MONTH Function
DAY Function
WEEKNUM Function
ISOWEEKNUM Function
HOUR Function
MINUTE Function
SECOND Function

Logical Functions
ISTODAY Function

Date & Time Information Functions
CALENDAR Function
CLOCK Function




Current Date & Time Functions



Today Function



Purpose
Returns the current date


Syntax

Today()


Example
Assume the current date & time is January 15, 2021 5:00:00 PM.

Today()  // Result: January 15, 2021


Now Function



Purpose
Returns the current date and time


Syntax

Now()


Example
Assume the current date & time is January 15, 2021 5:00:00 PM.

Now()  // Result: January 15, 2021 5:00 PM




Type Conversion Functions



Date Function



Purpose
Creates a date from a year, month and day


Syntax

Date(year, month, day)


Arguments

year – number for the year

month – number for the month (January is 1, February is 2, March is 3… December is 12)

day – number for the day


Examples

Date(2021, 1, 15)  // Result: January 15, 2021
Date(2021, 9, 4)   // Result: September 4, 2021
Date(2018, 3, 11)  // Result: March 11, 2018


Time Function



Purpose
Creates a time from hours, minutes and seconds


Syntax

Time(hours, minutes, second)


Arguments

hour – number for the hour (12AM is 0, 1AM is 1, 2AM is 2… 11PM is 23)

minute – number for the minute

second – number for the second


Examples

Time(2, 30, 0)   // Result: 2:30 AM
Time(14, 30, 0)  // Result: 2:30 PM
Time(19, 15, 10) // Result: 7:15:10 PM



A Date & Time can be combined into a single DateTime value like this:

Date(2021, 1, 20) + Time(14, 30, 0)  // Result: January 20, 2021, 2:30 PM


DateValue Function



Purpose
Converts a date stored as text into a date data-type


Syntax

DateValue(string [,language])


Arguments

string – text string containing a date

language [optional] – two letter language code, defaults to current user’s language


Examples

DateValue("January 15, 2021")  // Result: January 15, 2021 
DateValue("01/15/2021")        // Result: January 15, 2021


TimeValue Function


Purpose
Converts a time stored as text into a time data-type


Syntax

TimeValue(string [,language])


Arguments

string – text string containing a time

language [optional] – two letter language code, defaults to current user’s language


Examples

TimeValue("2:00 PM") // Result: 2:00 AM
TimeValue("17:00")   // Result: 2:00 PM


DateTimeValue Function



Purpose
Converts a date & time stored as text into a time data-type


Syntax

DateTimeValue(string [,language])


Arguments

string – text string containing a datetime

language [optional] – two letter language code, defaults to current user’s language


Example

DateTimeValue("October 11, 2014 1:50:24 PM")  // Result: October 11, 201 1:50:24 PM


Text Function


Purpose
Applies a date format and changes the data-type to text


Syntax #1

Text(NumberOrDateTime, DateTimeFormatEnum, [, ResultLanguageTag])


Arguments

NumberOrDateTime – text string containing a datetime

DateTimeFormatEnum – value belonging to the DateTimeFormat enum. See list below.

ResultLanguageTag [optional] – two letter language code, defaults to current user’s language


Example
Assume the current date & time is January 15, 2021 5:00:00 PM.

Text(Today(), "m/d/yyyy")  // Result: "1/15/2021"



Syntax #2

Text( NumberOrDateTime, CustomFormat [, ResultLanguageTag ] )


Arguments

NumberOrDateTime – text string containing a datetime

Custom Format – text string with date formatting code. See list below.

ResultLanguageTag [optional] – two letter language code, defaults to current user’s language


Example
Assume the current date & time is January 15, 2021 5:00:00 PM

Text(Today(), "m/d/yyyy")  // Result: "1/15/2021"



Syntax #3

Text(NumberOrDateTime)


Arguments

NumberOrDateTime – text string containing a datetime


Example
Assume the current date & time is January 15, 2021 5:00:00 PM.

Text(Today())  // Result: "1/15/2021"



Date and Time Formatting Codes
Use these formatting codes in the 2nd parameter of the Text function.

Enum FormatText FormatResult
LongDate“dddd, mmmm d, yyyy”“Friday, January 15, 2021”
LongDateTime“dddd, mmmm d, yyyy hh:mm:ss AM/PM”“Friday, January 15, 2021 5:00:00 PM”
LongDateTime24“dddd, mmmm d, yyyy hh:mm:ss”“Friday, January 15, 2021 17:00:00”
LongTime“hh:mm:ss AM/PM”“5:00:00 PM”
LongTime24“hh:mm:ss”“17:00:00”
ShortDate“m/d/yyyy”“1/15/2021”
ShortDateTime“m/d/yyyy hh:mm AM/PM”“1/15/2021 5:00 PM”
ShortDateTime24“m/d/yyyy hh:mm”“1/15/2021 17:00:00”
ShortTime“hh:mm AM/PM”“5:00 PM”
ShortTime24“hh:mm”“17:00”
UTC“2021-01-15T23:00:00.000Z”




Date & Time Manipulation Functions



DateAdd Function


Purpose
Adds a number or days to a date & time value. Can also add another time unit such as hours or months. If a negative number is supplied the number of time units will be subtracted.


Syntax

DateAdd(DateTime, Addition, [, Units])


Arguments

DateTime – date and time value

Addition – number of days or other time units to add to the DateTime

Units [optional] – one of the following enum values: Years, Quarters, Months, Days, Hours, Minutes, Seconds or Milleseconds. Default units are days.


Examples
Assume the current date & time is January 15, 2021 5:00:00 PM.

DateAdd(Today(), 7)          // Result: January 22, 2021
DateAdd(Today(), 2, Months)  // Result: March 15, 2021
DateAdd(Today(), -1, Years)  // Result: January 15, 2020


DateDiff Function


Purpose
Finds the a number or days between a start date and an end date. Can also add another time unit (e.g. hours, months)


Syntax

DateDiff(StartDateTime, EndDateTime, [, Units])


Arguments

StartDateTime – starting date and time value

EndDateTime – ending date and time value

Units [optional] – one of the following enum values: Years, Quarters, Months, Days, Hours, Minutes, Seconds orMilleseconds. Default units are days.


Examples
Assume the current date & time is January 15, 2021 5:00:00 PM.

DateDiff(Today(), Date(2021, 01, 20), Days)  // Result: 5 days
DateDiff(Date(2021, 01, 15)+Time(9, 0, 0), Today(), Hours)  // Result: 8 hours 


TimeZoneOffset Function


Purpose
Returns the number of minutes between the user’s local time and Universal Co-ordinated Time (UTC)


Syntax

TimeZoneOffset()


Examples
Converts the user’s local time to UTC. Assume the user’s local current date & time is January 15, 2021 5:00:00 PM

DateAdd(
    Now(),
    TimeZoneOffset(),
    Minutes
)                

// Result: January 15, 11:00PM



Converts UTC to the user’s local time. Assume the current UTC date & time is January 15, 2021 11:00:00 PM

DateAdd(
    StartTime,
    −TimeZoneOffset(StartTime),
    Minutes
)

// Result: January 15, 5:00PM





Date & Time Parsing Functions



Year Function, Month Function, Day Function, WeekNum Function, ISOWeekNum Function, Hour Function, Minute Function, Second Function



Purpose
Extracts an single part of the date & time value


Syntax

Year()

Month()

Day()

WeekNum()

ISOWeekNumber()

Hour()

Minute()

Second()


Examples
Assume the current date & time is January 15, 2021 5:00:00 PM.

Year(Now())        // Result: 2021
Month(Now())       // Result: 1
Day(Now())         // Result: 15
WeekNum(Now())     // Result: 3
ISOWeekNum(Now())  // Result: 2
Hour(Now())        // Result: 17
Minute(Now())      // Result: 0
Second(Now())      // Result: 0




Logical Functions



IsToday Function


Purpose
Checks whether a date & time value is within the current day and returns a true/false value.


Syntax

IsToday(DateTime)


Arguments

DateTime – a date & time value to compare


Examples
Assume the user’s local current date & time is January 15, 2021 5:00:00 PM.

IsToday(Date(2021, 1, 15)  // Result: true
IsToday(Date(2021, 1, 22)  // Result: false




Date & Time Information Functions


Calendar Function


Purpose
Returns calendar information for the user’s current locale.


Syntax

Calendar.MonthsLong()

Calendar.MonthsShort()

Calendar.WeekdaysLong()

Calendar.WeekdaysShort()


Examples

FormulaResult
Calendar.MonthsLong()[ “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” ]
Calendar.MonthsShort()[ “Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec” ]
Calendar.WeekdaysLong()[ “Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday” ]
Calendar.WeekdaysShort()[ “Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat” ]


Clock Function


Purpose
Returns clock information for the user’s current locale.


Syntax

Clock.AmPm()

Clock.AmPmShort()

Clock.IsClock24()


Examples

FormulaResult
Clock.AmPm()[ “AM”, “PM” ]
Clock.AmPmShort()[ “A”, “P” ]
Clock.IsClock24()FALSE





Questions?

If you have any questions or feedback about All Power Apps Date & Time Functions (With Examples) please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest
14 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Valerie Schaffer
Valerie Schaffer
8 months ago

I like having all this in one place, and where there are real-world examples. You should be writing the docs on Microsoft.

Nuno Nougiera
8 months ago

URLs are broken.

Minte
Minte
8 months ago

Thank you, this is a comprehensive documentation to check for date and time functions.

I wish you have added an example about an age calculation as part of the examples. Last week I had to calculate an age with Year and months and used the below formula. Look forward to hear from you if there is a shorter version to the below formula.
If(
!IsBlank(varRecord.DOB),
If(
DateDiff(
Today(),
Date(
Year(Now()),
Month(lbl_DOB.Text),
Day(lbl_DOB.Text)
)
) Month(lbl_DOB.Text),
Month(Today()) – Month(lbl_DOB.Text),
Month(Today()) = Month(lbl_DOB.Text) && (Day(Today()) >= Day(lbl_DOB.Text)),
“0”,
Month(Today()) + 12 – Month(lbl_DOB.Text)
) & ” month(s)”,
“”
)

Rachel Irabor
Rachel Irabor
7 months ago

Hi Matthew, started reading your articles recently and I am loving them thank you very much.

I don’t know if I am explaining this well, but I am trying to create an app using power apps and I need help with date manipulation.

How can I set up a particular date and time a service will be available and the date it would end without being able to bypass it example the date a room will be available in a hotel and the amount of days the room will be available and can not exceed that time. Thank you

Jeremy Arnold
Jeremy Arnold
6 months ago

Hi Matthew, your articles are great. I’m using the one on “Edit A Record With A Patch Form” and am running into some issues with dates, radio buttons, and people. Everything is fine until I create the submit button. It then breaks my gallery and a couple of labels on my submit form. The purpose of the app is for someone to review a procedure and say whether it is accurate or not. So I’m just passing the record variable through for the document number and title into a label. I want the Radio to default to blank, the reviewer to be auto filled to current user(Label Text is: User().FullName), and the date to be auto filled(Default date is Today()).
The doc number and title are text in SP, Radio is a Choice, Date is Date/Time, and Reviewer is Person or Group.

Here is the code in the submit button:
// submit the form data
Set( //<– new code
  varCurrentRecord,
  Patch(
    ‘Finishing LOTO Updates’,
    varCurrentRecord, // <– new code
    {
      DocumentNumber: GalDocNumber.Text,
      DocumentTitle: GalDocName.Text,
      ProcedureIsAccurate: Radio1.Selected.Value,
      Reviewer: ‘Current User_1’.Text,
      DateofLastReview: DatePicker1.SelectedDate
    }
  )
)

What am I doing wrong? Thanks!

Jason Roberts
Jason Roberts
3 months ago

Awesome resource. – Thanks, Matthew!

Bujjibabu KJ
Bujjibabu KJ
3 months ago

Hi
I have 3 Labels.
Label1 -StartTime
Label2-EndTime
Label3- Date Diff (Hours : Minutes)
Label1&2 I have used – Text(Now(), “[$-en-US]mm/ddd/yyyy hh:mm AM/PM”)
request you help me to achieve DateDiff in Hours : Minutes

Thanks & Regards
Bujjibabu KJ

Time Diff function in PowearApps.JPG
Luis
Luis
2 months ago

Great article! THANS!
Ihave an issue trying to inform the Form Submission time into email body, sent by my Flow. The submission date/time of my form, loaded in my SP list, looks ok, is the real date time value, BUT I can’t show it correctly in my email body. Sometimes is correct, most times is 2 hours back… What am I doing wrong? Why is it variable?
I’ve tried to use the form value (submission time), and also directly the sharepoint list field…..all in same Flow, after loading my SP list.
Any help will be appreciated.
Thanks!