viewed 1624 times and licensed 14 times
Converts serial Excel date into serial Julian date
View version details
Contents  |
|
Interface
#include <codecogs/units/date/exceltojulian.h>
using namespace Units::Date;
| int | excelToJulian (int ExcelDate, bool Mac=false) Converts serial Excel date into serial Julian date |
 | Integer | cc_excelToJulian (Integer ExcelDate, Boolean Mac) This function is available as a Microsoft Excel add-in. |
Function Documentation
This function converts the serial numbers that Excel use to represent dates, into a serial Julian number, which is standard adopted by the CodeCogs library. It is the exact opposite of
julianToExcel.
Excel only understands the Gregorian date system, but for added confusion Microsoft have chosen to present dates differently under the Windows and Apple OSX operating systems (though you can change this default behaviour):
- 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.
On a Windows platform the calculation to get the serial Julian date is:
On a Mac (OSX) you add an extra

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)
Page Comments
You must login to leave a messge
Last Modified: 18 Oct 07 @ 17:07 Page Rendered: 2010-03-13 00:26:52