Convert timestamp to datetime

Hi there is there anyway to convert the timestamp to a datetime?
I have a table with datetime column (sql query) in it and I want to pass the value with payload when click on the table row to a datepicker. It passes the datetime but in a timestamp format…

image

but I want it to be
image

You could do this through scripting I’m sure, but you could also pass the value to a placeholder property (key in my example), then bind a property (probably DateTimeInput.props.value) to the placeholder and apply a Format transform.

1 Like

You could also try this:

from datetime import datetime
return datetime.fromtimestamp(value/1000)

where value is the t_stamp value. This works for me when attempting to convert a t_stamp (big int) column from a MySQL table.

Eschew Python’s datetime - use system.date.parse or system.date.fromMillis to construct Java Date objects.

3 Likes

Just to add onto @PGriffith’s response, using Java Date Objects lets you use system.db.runPrepUpdate and not have to do any further date/string manipulation, which is very helpful.

3 Likes

Thanks guys for the solutions :+1:
Learnt something new :smiley:

1 Like