julian To Excel
Converts serial Julian date into serial Excel date
Controller:
CodeCogs
Interface
#include <codecogs/units/date/juliantoexcel.h>
using namespace Units::Date;
| int | julianToExcel (int nDate, bool Mac=false)
Converts serial Julian date into serial Excel date |
Use the following HTML code to embed the calculators within other websites:
| Name | HTML Code |
|---|
julianToExcel
Converts serial Julian date into serial Excel date | |
JulianToExcel
This function converts the serial Julian date that we use as standard in the CodeCogs library into the single value that Excel uses to represent dates. It is the exact opposite of
excelToJulian.
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 Excel date from a Julian number is:
On a Mac (OSX) you subtract an extra

Example 1
#include <stdio.h>
#include <codecogs/units/date/juliantoexcel.h>
#include <codecogs/units/date/date.h>
using namespace Units::Date;
int main()
{
printf("\nIf you type %d into Excel on a Mac, you get valentines day - don't forget!",
julianToExcel(date("14 feb 2005"), true)); // 27076
return 0;
}
- false: from Window Excel values using 1/1/1900.
- true: from 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, default for Windows Excel. We can not generate the 29/2/1900 from any Julian values (because it really doesn't exist), however for earlier days we simply subtract one from the Excel values.
Parameters
| nDate | 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.
You must login to leave a messge