Julian Date conversion question

Said
Member Posts: 20
Hi,
Does anyone know how to convert a Julian Date (eg. 731578) into Navision date field format?
Thanks in advance
Does anyone know how to convert a Julian Date (eg. 731578) into Navision date field format?
Thanks in advance
0
Comments
-
Add the Julian date to whatever the base date is for your Julian calendar. For example, 01010000D + 731578 produces 12292002D.0
-
That's interesting.
Does anybody know the base date for the Julian calendar?Timo Lässer
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]0 -
Look at http://www.tondering.dk/claus/cal/node3 ... 0000000000
there are formulas to calc from gregorian to julian and back...
or use convertor on http://www.fourmilab.ch/documents/calendar/0 -
Thank you for all replies.
But when I'm setting the refDate - I got the message that the refDate is not a valid date... What am I doing wrong?
Expr1 := 'CQ+1M-10D'; // Current quarter + 1 month - 10 days
Expr2 := '-WD2'; // The last weekday no.2, (last Tuesday)
Expr3 := 'CM+30D'; // Current month + 30 days
RefDate := 12292002D;
Date1 := CALCDATE(Expr1, RefDate);
Date2 := CALCDATE(Expr2, RefDate);
Date3 := CALCDATE(Expr3, RefDate);
MESSAGE(Text000 + Text001 + Text002 + Text003,
RefDate, Expr1, Date1, Expr2, Date2, Expr3, Date3);0 -
-
Just tried...Still no luck. Same error - not a valid date...0
-
ahhh... yes, I overlooked it - you must enter 29122002D --- it is ddmmyyyy...0
-
Has anyone created a codeunit with Julian2Gregorian and Gregorian2Julian?Timo Lässer
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]0 -
Timo Lässer wrote:Has anyone created a codeunit with Julian2Gregorian and Gregorian2Julian?
Now, I have created such functions:JulianDayNo2GregorianDate(JulianDate : Integer) : Date JulianDayNo2JulianDate(JulianDate : Integer) : Date GregorianDate2JulianDayNo(GregorianDate : Date) : Integer JulianDate2JulianDayNo(JulianDate : Date) : Integer
The functions are availible as download here:
http://www.msdynamics.de/dload.php?acti ... file_id=68
(I hope, it doesn't matter that the website is in german ;-) )Timo Lässer
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]0 -
DateToJulian(CalcDate : Date) : Decimal
Day := DATE2DMY(CalcDate,1); Month := DATE2DMY(CalcDate,2); Year := DATE2DMY(CalcDate,3); IF Year < 100 THEN ERROR('At least four digit year required.'); IF (Month < 1) OR (Month > 12) THEN ERROR('Invalid Month'); IF (Day < 1) OR (Day > 31) THEN ERROR('Invalid Day'); TempInt := (Month - 14) DIV 12; JulianDate := Day - 32075 + (1461 * (Year + 4800 + TempInt) DIV 4); JulianDate := JulianDate + (367 * (Month - 2 - TempInt * 12) DIV 12); JulianDate := JulianDate - (3 * ((Year + 4900 + TempInt) DIV 100) DIV 4); EXIT(JulianDate);
JulianToDate(JulianDate : Decimal) : Datel := JulianDate + 68569.0; n := (4 * l) DIV 146097; l := l - ((146097 * n + 3) DIV 4); i := (4000 * (l + 1)) DIV 1461001; l := l - ((1461 * i) DIV 4) + 31; j := (80 * l) DIV 2447; k := l - (2447 * j) DIV 80; l := j DIV 11; j := j + 2 - 12 * l; i := 100 * (n - 49) + i + l; Year := i DIV 1; Month := j DIV 1; Day := k DIV 1; EXIT(DMY2DATE(Day,Month,Year));
0 -
Date2YYDDD(DateIn : Date) YYDDD : Code[5] Year:=DATE2DMY(DateIn,3); Day := DateIn - CALCDATE('-CY',DateIn) +1; YYDDD:=COPYSTR(FORMAT(Year),3,2); YYDDD:=YYDDD+FORMAT(Day,3); YYDDD:=CONVERTSTR(YYDDD,' ','0');
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions