Skip to main content
1-Visitor
April 3, 2020
Solved

Timestamp to DATE

  • April 3, 2020
  • 2 replies
  • 2784 views

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

Best answer by iguerra

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

ConvertedDate = new Date(unix_timesamp * 1000);

 

2 replies

17-Peridot
April 3, 2020

Hi,

 

Try this in a service:

 

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

 

Hope it helps,

Raluca Edu

ketanaga1-VisitorAuthor
1-Visitor
April 8, 2020

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

iguerra16-PearlAnswer
16-Pearl
April 8, 2020

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

ConvertedDate = new Date(unix_timesamp * 1000);

 

Community Manager
April 15, 2020

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