Skip to main content
Apr 3, 2020 7:49 AM UTC
Solved

Timestamp to DATE

Hi 

 

I am using a CSV parser extension to import a CSV file from the local machine. The timestamp is in UNIX format and I want to convert it into a proper DATETIME format. The datashape basetype for Timestamp is number.

Is there a way to convert it into

iguerraAnswer
Apr 8, 2020 11:02 AM UTC

Try looping your result infotable, and for each row assign the new date with this logic

ConvertedDate = new Date(unix_timesamp * 1000);

 

4 replies

Apr 3, 2020 8:41 AM UTC

Hi,

 

Try this in a service:

 

var date = new Date(timestamp * 1000);
result= date;

 

Hope it helps,

Raluca Edu

ketanagaAuthor
Apr 8, 2020 7:50 AM UTC

Hi raluca_edu

 

Thanks for the quick response.

What I am trying to do here is getting the Timestamp values from the CSV file and I want them to be converted into DATETIME(for which you have given the snippet). I am stuck at a point where I want to convert the entire Timestamp column and the result should be in the same Infotable with Date column and Basetype already initialised in the Datashape

Attached is a screenshot of the service result. I want the DATETIME result to be populated there itself

iguerraAnswer
Apr 8, 2020 11:02 AM UTC

Try looping your result infotable, and for each row assign the new date with this logic

ConvertedDate = new Date(unix_timesamp * 1000);

 

Apr 15, 2020 7:30 PM UTC

Hi @ketanaga.

 

If one of the previous responses answered your question, please mark the appropriate one as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon