cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
RichV
Level: Powered On

Adjust DateTime for UTC

OK I am having nothing but difficulty with something that should be easy but cannot seem to find the correct answer. I have a DataTable that is being Filtered and then only Displaying the Last item. On it I need to display the Date and Time. The DataSource is an SQL Database and with the Column set as DateTime2. In the Table the Date and Time are correct but the App displays the UTC time (-4 hours).  I have Tried to do the AddColumns to format he Date Column with an added 4 hrs but it is not working. This is what I am using below....

 

AddColumns(Last(Filter('[prod].[ProductionData]', "Extruder3" in Machine)),"LastRecord", Text(DateAdd(Date,4,Hours)"dd-mm-yyyy hh:mm"))

The Date is the name of the Column in the Table and I believe is part of the issue but I also get an error when I changed it to Now(). It complains about the Text Portion. I am new to all this and could use some help to display this properly .

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Adjust DateTime for UTC

@RichV 

Uggg - stinging feeling of face plant slowly going away...

 

YES - this will not work.  Had to step back for a moment and think it through in my head...

We were trying to add a column to a single record (Last).  You have to add columns to a table.

 

So, your formula should be this:

 

Last(
AddColumns(
Filter('[prod].[ProductionData]', "Extruder3" in Machine), "LastRecord", Text(DateAdd(Date, -TimeZoneOffset(Date), Minutes), "dd-mm-yyyy hh:mm")
)
)

In this we are adding the columns to the Filter results table (allowed) and then taking the last record.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

7 REPLIES 7
Super User
Super User

Re: Adjust DateTime for UTC

@RichV 

 

If that is your formula, then you do have a syntax error in it.  There should be a comma before the format...see this:

 

AddColumns(Last(Filter('[prod].[ProductionData]', "Extruder3" in Machine)),"LastRecord", Text(DateAdd(Date,4,Hours),"dd-mm-yyyy hh:mm"))

However, you still might want to take advantage of the TimeZoneOffset function in PowerApps to adjust your times properly from UTC.

 

Something like this for example:

 

AddColumns(Last(Filter('[prod].[ProductionData]', "Extruder3" in Machine)),
"LastRecord", Text(DateAdd(Date, -TimeZoneOffset(Date), Minutes), "dd-mm-yyyy hh:mm"))

 

See if that is helpful for you.

 

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
RichV
Level: Powered On

Re: Adjust DateTime for UTC

It still is complaining I think the issue is the Column Name Date is not being accepted or something . 

Image 4.jpg

Super User
Super User

Re: Adjust DateTime for UTC

@RichV 

If that's the case, then rename the column...

 

AddColumns(Last(RenameColumns(Filter('[prod].[ProductionData]', "Extruder3" in Machine), "Date", "myDate")),
   "LastRecord", Text(DateAdd(myDate, -TimeZoneOffset(myDate), Minutes), "dd-mm-yyyy hh:mm"))
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
RichV
Level: Powered On

Re: Adjust DateTime for UTC

Odd it doesn't like it still. I ended up adding a Gallary instead and modified the Control to format using DateAdd(Date,4,Hours) and it worked fine. It worked just as well using the TimeZone option too. Not sure why it will not work with AddColumns and the datatable.

Super User
Super User

Re: Adjust DateTime for UTC

@RichV 

Uggg - stinging feeling of face plant slowly going away...

 

YES - this will not work.  Had to step back for a moment and think it through in my head...

We were trying to add a column to a single record (Last).  You have to add columns to a table.

 

So, your formula should be this:

 

Last(
AddColumns(
Filter('[prod].[ProductionData]', "Extruder3" in Machine), "LastRecord", Text(DateAdd(Date, -TimeZoneOffset(Date), Minutes), "dd-mm-yyyy hh:mm")
)
)

In this we are adding the columns to the Filter results table (allowed) and then taking the last record.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

RichV
Level: Powered On

Re: Adjust DateTime for UTC

Perfect!!!! Yeah that was it and makes perfect sense. I'm always learning. THANKS

raheelrMCG
Level: Powered On

Re: Adjust DateTime for UTC

@RandyHayes  Thanks . Was stuck on this since yesterday. 

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,448)