web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / DateValue and Timezone...
Power Apps
Answered

DateValue and TimezoneOffset?

(0) ShareShare
ReportReport
Posted on by

I've got an interesting problem for ya!

Scenario:

- Column "PLN_STRT_DT" in the data source is in ISO8601 format (yyyy-mm-ddThh:MM:ssZ) 

- I'm using some handy dandy code to make the Combobox tied to this column more user friendly:

 

SortByColumns(
 GroupBy(
 AddColumns(
 Distinct(
 colAllRecords,
 PLN_STRT_DT
 ),
 "planStartDateFormatted",
 Text(DateTimeValue(Result), "[$-en-US] mm/yyyy") //<--ISSUE IS HERE
 ),
 "planStartDateFormatted",
 "test"
 ),
 "planStartDateFormatted",
 Ascending
)

 

 

The problem:

- I'm finding that the PowerApps DateTimeValue() function is converting the raw timestamp of:

- 2022-01-01T00:00:00Z to

- 2021-12-31 4:00PM (UTC - 8hrs which is PST where I'm sitting). 

- This causes problems with the GroupBy() logic. 

 

The question:

- How do I use TimezoneOffset() with DateTimeValue() to keep the times aligned?

 

Example:

- From within a Gallery, here is (LEFT) DateTimeValue(Text(Trim(ThisItem.PLN_STRT_DT), "mm/dd/yyyy")) and (RIGHT) ThisItem.PLN_STRT_DT. 

- I need the LEFT value to be 12/31/2021, NOT 12/30/2021

ericonline_0-1611092433773.png

Really becomes apparent here where the issue causes data to fall into different YEARS, not just days:

ericonline_0-1611093647124.png

 

 

It looks like DateTimeOffset() only works with DateAdd() function? Its counterintuitive for me to use DateAdd() rather than Text(DateTimeValue(Result), "mm/yyyy") to convert the timestamp. 

 

Thoughts?


Thank you

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @ericonline 

    This topic sounds familiar! 😉

     

    Consider the following formula:

    SortByColumns(
     GroupBy(
     AddColumns(
     Distinct(
     colAllRecords,
     PLN_STRT_DT
     ),
     "planStartDateFormatted",
     Text(
     DateAdd(DateTimeValue(Result), 
     -TimeZoneOffset(DateTimeValue(Result)), 
     Minutes
     ), 
     "[$-en-US] mm/yyyy") //<--ISSUE IS GONE - HOPEFULLY!!
     ),
     "planStartDateFormatted",
     "test"
     ),
     "planStartDateFormatted",
     Ascending
    )

    I hope this is helpful for you. 

  • Community Power Platform Member Profile Picture
    on at

    Yep, that got me real close! Only change was to remove the subtraction "-".

    Adding the difference between my local timezone and UTC makes sense, but the conversion that DateTimeValue() does automatically does not make sense. 

    No biggie! 

    I posted a recommendation on the docs page to mention it.

    Dude! Thanks a bunch!

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @ericonline 

    Actually the minus should be what is needed. I believe the issue with the formula I suggested was that I was using the TimeZone information from the converted date time.  If that parameter for the timezoneoffset is left blank, it will use the current time zone.

     

    Anyway...I am glad you have what you need. Happy to help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard