-
Notifications
You must be signed in to change notification settings - Fork 274
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
Date formatted columns lose value in JSON? #17
Comments
I've noticed this as well. Almost like it's trying to perform an arithmetic operation on the value. |
Did some digging and it appears it's due to the xlsx module that this one depends on: Basically, the number being return is the number of days since the last epoch (1904 or 1900). |
so you may be able to do something like:
|
Do note, just encountered this. Excel has a leap year bug (http://support.microsoft.com/kb/214326) which causes the dates to be off by one if you do @snypelife's suggestion. So you will need to do an additional -1
|
@shyamseshadri so... this could work?
|
@uncedric little bit late of a reply, so probably don't need an answer anymore, but yes that would work. |
actually, it would have to be |
var date = new Date(1899, 0, dataVal - 1);
var date = new Date(1899, 12, dateVal ); 2016-06-01 |
10:00:00 will be converted to 9:59:59. |
@Vincentliu89 I met the same situation,i need help |
Date in my xlsx file was
then to format it properly I used moment.js lib so finally:
|
@Vincentliu89 @zhaoxinwei I need more clarity on your use case. May be u can explain me the date and time format you are storing in excel sheet. |
To fix this "10:00:00 will be converted to 9:59:59" |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm still having this issue. |
Use this |
how to optimize |
hi,i got a float value from Excel like '367.084722222222',how can i convert it to Date in javascript? |
The following code supports csv, xls, xlsx: // suffix: file extension
// add utf8 BOM Header(3bytes) 2.and forEach all columns: 3.if xlsx: |
May I ask why I have used it for 8 days longer? Is there any solution? |
The solutions by theromie, BumbuKhan and shyamseshadri work back to around the year 1600. Sadly, when you have historic data that's older, it gets inaccurate. Time is an issue on it's own. Tests: https://jsfiddle.net/cehu8wgt/ |
why? |
Upstream tracking issue SheetJS/sheetjs#1565 . A part of the overall date issues stem from a V8JS (Chrome / NodeJS JavaScript engine) bug which can be tracked at https://bugs.chromium.org/p/v8/issues/detail?id=7863 FWIW none of the simple datecode translations are correct around DST dates like a few days ago (Nov 7 was rollback day for Eastern Time). JS engines perceived the logical day to have 90000 seconds while Excel treats every day as if it has 86400 seconds. PS @timohausmann in the 1900 date system (most common), the smallest valid datecode is 0. Excel understands this to be "1900-01-00" which is commonly understood by humans to be the midnight of December 31 1899. A number of timezones including Asia/Hong_Kong and Europe/Paris aligned to a v8-friendly timezone after 1900. Depending on your timezone, you will find different dates which "work" |
I am having the same issue my excel has |
Hi there! Is there a way to read in data from an Excel sheet so that it retains the date? When I try to read in date-formatted columns (such as 11/4/14) it gives it a value of 41947 in the JSON object.
The text was updated successfully, but these errors were encountered: