# CFLib.org – Common Function Library Project

## GetDateFromJulianDay(JulianDay)

##### Last updated September 5, 2001

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Calculates the date and time from a provided Julian Day value.

Return Values:
Returns a date/time object.

Example:

``````<CFSET JD = getJulianDay()>
<CFOUTPUT>Today's Julian Day is: #JD# which gives us back today's date: #GetDateFromJulianDay(JD)#</CFOUTPUT>``````

Parameters:

Name Description Required
JulianDay Value representing the Julian day you want to retrieve the date/time for. Yes

Full UDF Source:

``````/**
* Calculates the date and time from a provided Julian Day value.
*
* @param JulianDay 	 Value representing the Julian day you want to retrieve the date/time for.
* @return Returns a date/time object.
* @author Beau A.C. Harbin (bharbin@figleaf.com)
* @version 1.0, September 5, 2001
*/
function GetDateFromJulianDay(JulianDay){
var a = 0;
var b = 0;
var c = 0;
var d = 0;
var e = 0;
var m = 0;
var date = 0;
var JD = JulianDay;
var time = 0;

a = JD + 32044;
b = ((4 * a) + 3) \ 146097;
c = a - (b * 146097) \ 4;
d = (4 * c + 3) \ 1461;
e = c - ((1461 * d) \ 4);
m = (5 * e + 2) \ 153;

time = TimeFormat(JulianDay, "HH:MM:SS");
date = DateAdd("h", 12, CreateDateTime(((b * 100) + d - 4800 + (m \ 10)), (m + 3 - (12 * (m \ 10))), ((e - (153 * m + 2) \ 5) + 1), DatePart("h", time), DatePart("n", time), DatePart("s", time)));

return date;
}``````

date2ExcelDate
May 5, 2016

CapFirst
April 25, 2016