Convert String/Number into Julian Date

nick_bc

nick_bc

Active Member
Hello All,

I am pretty new to the JDE report writing and I need a very urgent help. How to convert a sting (which is having a julian date format ie. CYYDDD where c stands for century, YY stand for Year and DDD stand for Day of the year 103001 stand for Jan 1, 2003). A quick reply will really appreciated. Thanks in advance[crazy]
 
Here's a list of usefull functions including date conversions:

.B0000164 - Set Currency Decimals
.B8300007 - User Defined Date Title
.N4002400 - F983051 Get Version Title to retrieve
.XX0901 - Validate Account Number
.B0000580 - Convert String to Math Numeric
.B0000045 - Math Numeric to String
.X0005 - Get UDC
.B4002070 - Get/Update UDC Description
.B8000002 - Delete All Rows from Table
.B0000127: ReturnTodaysDate
.B0700068: RetrieveDayofWeek
.B4201480: GetDayofWeek
.B0800013: ConvertStringToDate
.B3000250: GetMonthDescription
.B3000260: GetYearDescription
.B41B0470: FormatDateFromDMY
.B7600920: ConvertNumbersAndDatesToString
.B9100001: ConvertjulianDatetojdeDate
.B9800210: Convert From and To Julian Date from JDEDATE
.B9800460: ConvertDateToString



Colin Dawes, Sr. Technical Consultant
Syntax.net
B733.1 to ERP 8.0
Oracle 8i/9i/SQL Server 2K, DB2
 
Try B9800210
This bsfn take a Julian Date in the Format of YYYYDDD and convert to JDEDATE format
 
Any other advise? Nothings seems working to convert a string to julian date
 
Hi Naveen :

I may help, but would need you to answer me a couple of questions :
What is the format of your string? YYYYMMDD? DD/MM/YY? MM-DD-YY?
What language or tool would you like to use to convert your string to julian
date? ANSI C?
Crystal Reports? Visual Basic? T-SQL?

Regards, Sebastian
 
Have you tried to convert the string to a numeric before converting to the JDE Date format?

- Scott
 
Re: RE: Convert String/Number into Julian Date

I am using Report Writing Tool of JDE. from the form, Date is get converted into julianformat and then string into a string field 30 char. long. first 24 char are used by spces and last 6 char. stored as string in julian format. What i want to do is to coverted this juliandate (sring) to date in a report variable and then map it to the Table I/O for further reporting. I want DD/MM/YYYY from the string.
 
Re: RE: Convert String/Number into Julian Date

Naveen,

I Wrote this C function that do the JOB :

Function take as input CYYDDD and return a JDE Date. then you can display in the format you want

Ex : 103001 ---> 01/01/2003 (JDEDate)


Christian
PS : This code was based on a JDE Function that was incomplete for our needs and I don't remember the original BSFN Number.

-----------------------------------------------------

JDEBFRTN (ID) JDEBFWINAPI PWCConvertJulianDateToJDEDate (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD58001 lpDS)
{
/************************************************************************
* Variable declarations
************************************************************************/
int uMonth = 1 ;
int uYears = 0 ;
int uJulianDays = 0 ;
int uIsLeapYear = 0;

int uDaysInMonth[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30,
31, 30, 31 } ;
long uJulianDate = 0L ;

JDEDATE jdWorkDate = { 0, 0, 0 } ;

/************************************************************************
* Declare structures
************************************************************************/

/************************************************************************
* Declare pointers
************************************************************************/

/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD58001) NULL))
{
jdeSetGBRError (lpBhvrCom, lpVoid, (ID) 0, "4363");
return ER_ERROR ;
}

/************************************************************************
* Set pointers
************************************************************************/

/************************************************************************
* Main Processing
************************************************************************/

/*Copie de la date à convertir dans un work field*/
MathNumericToLong ( &lpDS->mnJulianDateInYYYDDD, &uJulianDate ) ;

/*Calcul du nombre d'année et du nombre de jours de la date*/
uYears = (int) (uJulianDate / 1000 ) ;
uJulianDays = (int) (uJulianDate % 1000 ) ;


/*On ajoute 1900 pour obtenir la VRAI année 101 + 1900 = 2001 et 99 + 1900 = 1999*/
jdWorkDate.nYear = (short) (uYears + 1900);

/*Vérification d'une année bissextile*/
if ( (jdWorkDate.nYear > 0) &&
((jdWorkDate.nYear % 4 == 0 && jdWorkDate.nYear % 100 != 0) ||
(jdWorkDate.nYear % 400 == 0)))
{
uIsLeapYear = 1;
}

if ( uJulianDate > 0 && uYears > 0 )
{

/*On commence en Janvier au jour UN*/
jdWorkDate.nMonth = 1 ;
jdWorkDate.nDay = 1 ;

if (uIsLeapYear)
{
uDaysInMonth[2] = 29 ; /* les années bissextile on 29 jours en février*/
}

/*Calcul du mois de la date en cours*/
while (uMonth <= 12 && (uJulianDays > uDaysInMonth[uMonth]))
{
uJulianDays = uJulianDays - uDaysInMonth[uMonth] ;
uMonth = uMonth + 1 ;
}
/*Transfert le jour et le mois dans le Work Date*/
jdWorkDate.nDay = (short) uJulianDays;
jdWorkDate.nMonth = (short) uMonth ;
}


memcpy ( (void *)(&lpDS->jdDateConverted),
(const void *)(&jdWorkDate), sizeof(JDEDATE) ) ;

/************************************************************************
* Function Clean Up
************************************************************************/

return (ER_SUCCESS);
}
 
Re: RE: Convert String/Number into Julian Date

I've found the JDE BSFN that I've base my code on but don't use it because it's not compliant with YEAR 2000. it's B9800210

Christian
 
Re: RE: Convert String/Number into Julian Date

[side-note] Leap Years?

I guess we'll just avoid them?

db
<grin>
 
Back
Top