-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with reading dates #395
Comments
Excel stores dates as numbers - check out http://www.cpearson.com/excel/datetime.htm I cant figure out if its up to alasql to convert this to a date. It probably is - but then we get the whole issue of formatting dates. You can try to mark the colmn and format cells as text |
I'm with this problem too. |
Hi @lganet Sorry to hear that you are having same issues still not saved. If you find any way to sort out the data from excel please share your inputs here. |
Hi mathiasrw and lganet This solution for it. Used this code to convert date.
|
Awesome! Thank you so much. I will see if we can get this into the lib some way |
Hi, just adding this way of calculating which seems simpler: function sheetDateToJSDate(n) {
const d = new Date(1899, 11, 30)
d.setDate(d.getDate() + n)
// Rounds milliseconds to seconds
d.setSeconds(d.getSeconds() + Math.round(d.getMilliseconds() / 1000))
d.setMilliseconds(0)
return d
} |
Hi,, I have also get same issue, above solution gives approximate datetime values only.
@UdayangaSeram solutions gives @caesarsol solutions gives 43009.4222222222 ' : ' 2017-10-01T04:38:00.000Z After some googled i found the solutions use this npm package to solve
Credits goes to : Thanks, |
xlsx library actually supports this already by setting 'cellDates: true' in the read function. (it becomes a date object) try
vs
Is there any way to pass config to the xlsx library via alasql? |
Hmmm - it should already just pass the config array to xlsx... If anyone can look into the src folder that would be awesome (I'm at vacation at the moment) |
@SamanthaAdrichem @mathiasrw I think we can pass the Line 387 in b5c449d
Line 46 in b5c449d
EDIT: think I found a better way in #1481 ; let the user provide options for XLSX.read themselves. |
Thanks @barakplasma Released as part of https://github.com/AlaSQL/alasql/releases/tag/v2.0.1 AlaSQL will now default to read dates as JS objects (cellDates = true). Read more on: https://github.com/AlaSQL/alasql/wiki/XLSX at the bottom. |
Hi Every one,
I have facing a problem in read dates. I am using the following query to read data from xls but all the date column of xls data automatically converted into integer why occur this problem? how to fix this problem?
alasql query:
alasql('SELECT * FROM FILE(?,{headers:true})', [event], function (res) { });
01/02/2015 this format is converted into 42006(int) Why? please help me
The text was updated successfully, but these errors were encountered: