Skip to content Skip to sidebar Skip to footer

Google Apps Script _ Convert Float To Date

I have a cell in my google spreadsheet with the value of 5/31/2016 0:22:38, but when I wrote a script to fetch the data it returns 42521.015713761575. I've tried some codes from jq

Solution 1:

This is apparently a number of days elapsed since December 30, 1899, 00:00:00.

You can convert it back to a UTC date with the following code (note that months are zero-based, so December = 11):

var x = 42521.015713761575;

// seconds in day = 24 * 60 * 60 = 86400var date = newDate(Date.UTC(1899, 11, 30, 0, 0, x * 86400));

console.log(date.toUTCString());

Post a Comment for "Google Apps Script _ Convert Float To Date"