Date Conversion

SSAJAROFF

Reputable Poster
Hi there...

A few routines for Date Conversion (from YYYYMMDD to OneWorld Julian)
They're written in a kind of GWBasic pseudo-code quite easy to
implement in Visual Basic, RPG, C++, etc.

DIM DateYMD AS STRING*8
DIM YStr AS STRING*4
DIM MStr AS STRING*2
DIM DStr AS STRING*2
DIM YNum AS INTEGER
DIM MNum AS INTEGER
DIM DNum AS INTEGER
DIM Julian AS LONG
DIM Counter AS INTEGER
REM Valid only from 1900.
PRINT "Enter Date YYYYMMDD"
INPUT DateYMD
YStr=LEFT(DateYMD,4)
MStr=MID(DateYMD,5,2)
DStr=RIGHT(DateYMD,2)
YNum=VAL(YStr)
MNum=VAL(MStr)
DNum=VAL(DStr)
Julian=(YNum-1900)*1000
Julian=Julian+DNum
FOR Counter=1 TO MNum-1
IF Counter=4 OR Counter=6 OR Counter=9 OR Counter=11 THEN
Julian=Julian+30
ELSE
IF Counter=2 THEN
IF YNum/4=INT(YNum/4)
IF YNum/100=INT(YNum/100) AND YNum/400=INT(YNum/400) THEN
Julian=Julian+29
ELSE
Julian=Julian+28
ENDIF
ELSE
Julian=Julian+28
ENDIF
ELSE
Julian=Julian+31
ENDIF
ENDIF
NEXT Counter
PRINT "Julian Date is ";Julian
END




B7321 to Xe, NT/W2K/SQL
JAS, Interoperability
MCDBA,MCP+I,MCSE,Citrix Admin
ssajaroff@grupoassa.com
Grupo ASSA - Application Software SA
 
Top