Converting date and time in data table from UTC to UTC+2

Currently I am pulling the date and time from a JSON object and it is returning the date and time in UTC(according to their API there is no way to change that time-zone). I would like the timestamp to be in UTC+2, I do not mind creating more columns to achieve this. Is there any way to do this through glide

Use a math column with the formula Date + 2/24

1 Like

Hi Darren, unfortunately this does not work. Am I doing something wrong? Like I said the dates get pulled from API then we either use JSON query or a Javascript to pull values(either work, but neither work for this math column.)

Screenshot 2023-10-31 080745
Screenshot 2023-10-31 080735
Screenshot 2023-10-31 080947
Screenshot 2023-10-31 080809

It looks like your Date is an ISO8601 Date string, rather than an actual date/time type.
You might need to convert it to a Date first using a Text to Date column. In fact, you should be able to do that and apply the UTC adjustment at the same time.

I have done this however it is not returning a value? (I also tried the original Javascript colum)
Screenshot 2023-10-31 083445

Also correct me if I am wrong but in my second post I showed a date format in which my values then became this and yet it still doesn’t work in the math column?
Screenshot 2023-10-31 092014

The Text to Date column expects an ISO8601 string by default (which is what you have), so you don’t need to provide any Format parameters. If you just pass your original date string with no additional parameters, it should return a Date object adjusted for your current time zone:

That will give you a Date value that the Math column will recognise. So if you need to add 2 hours (or whatever) you can do that using the earlier math formula that I gave you.

I copied exactly what you did however it is still returning it as a ISO string

Screenshot 2023-10-31 114510
Screenshot 2023-10-31 114521

Yes, if you click into the cell it will appear like that. But did you try passing it into a math column?

Yes thank you it did work, one last question a bit out of topic but the license plate text is in ISOstring too, also pulling using Javascript. How would I convert it into a text so that I can show it in my app layout?

Can you show me what it looks like?

Screenshot 2023-10-31 121140
Sure, here we go

So if you try and use that in a Text type component it doesn’t work?

I would expect that it should. And actually it does work for me.

Only difference I think is that I used a Query JSON column instead of JavaScript. But I shouldn’t expect that to make any difference.

Sorry I should have been more specific, so the point is for it to be a text entry field. That way if the plate recognizer does not show up with a number plate, they can enter a unique pin. If it does show up in our data then it automatically puts it into the text field. The text entry field does not allow for “special columns”. Hence trying to convert it.

I’m not sure I follow. Do you mean you want to use it as a default value for a Text Input?
That should be possible, depending on context. But you certainly can’t use it as the target of Text Input. And no amount of transformation will help with that, as you cannot write to computed columns.

Is it possible at all to convert a computed columns value into a basic column? It doesn’t matter how long or complicated it would be, but any links or advice would be appreciated. The problem is we pulled in a lot of information through an API in JSON format and now want to put that info into text entries(in case something doesn’t pull they can edit it themselves, see above example with number plates), and text entries only allow data from basic columns, not computed.

You can’t convert a column type from computed to non-computed. But you can take a computed value and write it into a non-computed column with either a Set Column Values or Add Row action. You just need something to trigger the action - a button or similar.

1 Like

Is there a way(if you aren’t too tired) you could come up with an example to show me? So lets say one column would have a maths component thats generated when a button action is triggered in your app, how would you set it up to write that value into a non-computed column?

This was my attempt however it is only showing the values for one row?..

Screenshot 2023-10-31 140859
Screenshot 2023-10-31 140912

Okay, you didn’t mention that you need to write multiple values into multiple rows. That makes a very big difference. The most effective way to do that is via the API. You’d need to prepare a mutation for each row, bundle that up into a JSON payload, and use a Call API action to send the payload.

If it’s for a small, fixed number of rows, then you could setup an action with multiple Set Column Values actions. But you’d need to first build a single relation (or single value->whole row) to every row. Quite messy, and doesn’t scale, but doable.