cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
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
Highlighted
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.
Highlighted
Frequent Visitor

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

Highlighted
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.
Highlighted
Frequent Visitor

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.

Highlighted
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

Highlighted
Frequent Visitor

Re: Adjust DateTime for UTC

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

Highlighted
Regular Visitor

Re: Adjust DateTime for UTC

@RandyHayes  Thanks . Was stuck on this since yesterday. 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (7,231)