CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Components

Valid RSS

UnitsDate

julian To Excel

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 0.50
sub units 0.00
add a commercial licence to your cart
0
viewed 1824 times and licensed 21 times

Converts serial Julian date into serial Excel date

Controller: CodeCogs  Contact Controller
+View version details
Contents hide toc
buy now     get GPL     add to cart

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

Function Documentation

Julian To Excel Calculator
  
Add calculator to website or email
 
intjulianToExcelintnDate
boolMac = false )
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):

On a Windows platform the calculation to get the serial Excel date from a Julian number is:

ExcelDate = nDate - 2415019

On a Mac (OSX) you subtract an extra 365*4 + 1
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;
}

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:
nDateis the serial number that Excel uses to represent dates.
Macis a switch to identify which base date to use:
Authors:
Will Bateman (Sep 2004)
Source Code:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

Not a member, then Register with CodeCogs. Already a Member, then Login.


Page Comments

Format Excel Equations

  You must login to leave a messge


Last Modified: 24 Jan 10 @ 15:53     Page Rendered: 2010-03-10 23:07:02

Valid CSS!   Valid XHTML 1.0 Transitional