Closed MMMUK1 closed 8 years ago
+1
@MMMUK1 Have you found that reading date cells as a string value makes the date off by one day?
Hi Nathan - thanks for response. I've found the string value to be some way off one day. Especially if Excel cell is not carefully formatted in dd/mm/yyyy format. For example if the cell is in "*dd/mm/yy" format, the string value can deliver a very strange value that appears to combine mm + yy and the string is a slave to single digits like d/m/yy (and the 'yy' is not necessarily the last 2 digits of the correct 'yyyy' year).
This was my workaround by the way:
NSInteger serialNo = [[cell value] integerValue];
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setYear:1900];
[components setMonth:1];
[components setDay:1];
NSDate *refDate = [cal dateFromComponents:components];
NSDate *dob = [refDate dateByAddingTimeInterval:60*60*24*(serialNo-2)];
[propertyDictionary setObject:dob forKey:propertyName];
Many thanks Nathan. That is an awesome workaround - forgot about serial number value. This 'workaround' is probably better and easier to follow rather than develop the library to inspect cell date formats/values. The serial number gives a direct date regardless of excel dd-mm-yy / mm-dd-yy country spreadsheet formatting. I think it's worth adding this approach to the README documentation to handle all Date matters.
Hi, The 'null' value is returned when using the dateValue getter. Is this expected?
I note there does not appear to be an example code of how to use the getter.
Any advice on this appreciated. M