I need to do some calculations with dates (adding and subtracting days mostly). I can do this in tradestation by using a function they call DateToJulian(). I then do my calculations and convert the result back using the inverse function, you guessed it JulianToDate()! (See below for definitions)
Now that I am converting all my code to PB i have to write these two functions. But short of a lookup table and some kind of compenstion for leap years I cant think of slick way to do it.
Are there any Win API calls that might do this?
-----------------------------------------------------------------
DateToJulian Function:
Returns the Julian date for the specified calendar date.
DateToJulian(cDate) ;
(cDate) is a numeric expression representing the date in the format YYYYMMDD
Remarks
If a specific date is entered for the numeric expression, it must be a valid date between January 1, 1901 and February 28, 2150
Examples
DateToJulian(980804) returns a value of 36011 for the date August 4, 1998.
DateToJulian(991024) returns a value of 36457 for the date October 24, 1999
---------------------------------------------------------------
JulianToDate Function:
Returns the calendar date for the specified Julian date.
JulianToDate(jDate) ;
(jDate) is a numeric expression representing the Julian date.
Examples
JulianToDate(36011) returns a value of 19980804 for the date August 4, 1998.
JulianToDate(36457) returns a value of 19991024 for the date October 24, 1999.
----------------------------------------------------------------
------------------
Kind Regards
Mike
Now that I am converting all my code to PB i have to write these two functions. But short of a lookup table and some kind of compenstion for leap years I cant think of slick way to do it.
Are there any Win API calls that might do this?
-----------------------------------------------------------------
DateToJulian Function:
Returns the Julian date for the specified calendar date.
DateToJulian(cDate) ;
(cDate) is a numeric expression representing the date in the format YYYYMMDD
Remarks
If a specific date is entered for the numeric expression, it must be a valid date between January 1, 1901 and February 28, 2150
Examples
DateToJulian(980804) returns a value of 36011 for the date August 4, 1998.
DateToJulian(991024) returns a value of 36457 for the date October 24, 1999
---------------------------------------------------------------
JulianToDate Function:
Returns the calendar date for the specified Julian date.
JulianToDate(jDate) ;
(jDate) is a numeric expression representing the Julian date.
Examples
JulianToDate(36011) returns a value of 19980804 for the date August 4, 1998.
JulianToDate(36457) returns a value of 19991024 for the date October 24, 1999.
----------------------------------------------------------------
------------------
Kind Regards
Mike
Comment