GetDateFromModifiedJulianDay(JulianDay)
Last updated September 05, 2001
Version: 1 | Requires: CF5 | Library: DateLib
Description:
Calculates the date and time based on a modified Julian Day.
Return Values:
Returns a date/time object.
Example:
<CFSET MJD = GetModifiedJulianDay()>
<CFOUTPUT>Today's modified Julian Day is: #MJD# which gives us back today's date: #GetDateFromModifiedJulianDay(MJD)#</CFOUTPUT>
Parameters:
Name | Description | Required |
---|---|---|
JulianDay | Value representing the modified Julian day you want to retrieve the date/time for. | Yes |
Full UDF Source:
/**
* Calculates the date and time based on a modified Julian Day.
*
* @param JulianDay Value representing the modified 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 getDateFromModifiedJulianDay(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 + 2400001) + 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 = 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;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016