Welcome! Log In Create A New Profile

Advanced

Julian date

Posted by John Marrone 
John Marrone
Julian date
February 07, 2009 03:01PM
Hi
Could somebody explain to me how to get a Julian date from a date in a string formatted like "20090207". Would greatly appreciate the help.
Merijn van der Wijk
Re: Julian date
February 07, 2009 11:25PM
John,

To my knowledge no W-language function available.
Seach he web for Julian date algorithm.
HTH
Merijn
Peter Holemans
Re: Julian date
February 09, 2009 12:26AM
Hi John,

Here's some class methods I use that do that... (Part of my objJDEHandler class I developed for use with some of my Oracle JDEdwards customers). If you see some code optimization opportunities, please let me know.

FUNCTION JDEToISODate(LOCAL pJDEDate is string)
//Local variables
ReturnDate is string = ""
JDEDay, JDEYear, JDECentury are int
ISODay, ISOMonth, ISOYear are string

IF Val(pJDEDate > 0) THEN
	SWITCH True
		CASE   1000 < Val(pJDEDate) < 10000
			JDECentury = 1900
			JDEYear = Val(Left(pJDEDate,1))
			JDEDay = Val(Right(pJDEDate,3))
		CASE  10000 < Val(pJDEDate) < 100000
			JDECentury = 1900
			JDEYear = Val(Left(pJDEDate,2))
			JDEDay = Val(Right(pJDEDate,3))
		CASE 100000 < Val(pJDEDate) < 1000000
			JDECentury = 2000
			JDEYear = Val(Middle(pJDEDate,2,2))
			JDEDay = Val(Right(pJDEDate,3))
	END
	ReturnDate = NumToString(JDECentury+JDEYear,"04d")+"0101"
	ReturnDate = IntegerToDate(DateToInteger(ReturnDate)+JDEDay)
	IF NOT DateValid(ReturnDate) THEN
		ReturnDate = ""
	END
END
RESULT ReturnDate


FUNCTION ISOToJDEDate(LOCAL pISODate is string)
//Local variables
ReturnDate is int = 0
JDEDateAsString is string = ""
ISODate is Date = pISODate
ISODay, ISOMonth, ISOYear are string

IF DateValid(ISODate) THEN
	IF ISODate..Year >= 2000 THEN JDEDateAsString = "1"
	JDEDateAsString += Right(NumToString(ISODate..Year,"04d"),2)
	JDEDateAsString += NumToString(DateToInteger(ISODate,True),"03d")
	ReturnDate = Val(JDEDateAsString)
END

RESULT ReturnDate


Cheers,
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: