excel To Julian
Converts serial Excel date into serial Julian date
Controller: CodeCogs
Interface
C++
Excel
ExcelToJulian
intexcelToJulian( | int | ExcelDate | |
bool | Mac = false | ) |
- the Windows standard: starts on the 1 January 1900, which is represented by 1.
- the Mac standard (Apple's OSX): starts on 1 January 1904, which is represented by 0.
Example 1
#include <stdio.h> #include <codecogs/units/date/exceltojulian.h> #include <codecogs/units/date/dateymd.h> using namespace Units::Date; int main() { for(int i=5555;i<5560;i++) { int y,m,d; dateYMD(excelToJulian(i),y,m,d); printf("\nWindows Excel use %d to represent %d-%d-%d",i, d,m,y); } return 0; }
Output:Windows Excel use 5555 to represent 17-3-1915 Windows Excel use 5556 to represent 18-3-1915 Windows Excel use 5557 to represent 19-3-1915 Windows Excel use 5558 to represent 20-3-1915 Windows Excel use 5559 to represent 21-3-1915
- false: to Window Excel values using 1/1/1900.
- true: to Mac Excel values using 1/1/1904.
Note
- Unfortunately Microsoft made a mistake, so they think 29/2/1900 exists - but 1900 isn't a leap year!! This clearly only has an impact in the 1900 date system, standard on Windows Excel. Therefore to handle this error, we simply assume an Excel value of 60 to correspond to 1/3/1900. While values below 60 are incremented by 1.
Parameters
ExcelDate is the serial number that Excel uses to represent dates. Mac is a switch to identify which base date to use:
Authors
- Will Bateman (Sep 2004)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.