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) : Date
l := 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));
Comments
Does anybody know the base date for the Julian calendar?
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
there are formulas to calc from gregorian to julian and back...
or use convertor on http://www.fourmilab.ch/documents/calendar/
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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);
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
Now, I have created such functions:
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 ;-) )
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
JulianToDate(JulianDate : Decimal) : Date
http://www.BiloBeauty.com
http://www.autismspeaks.org