I need some help with dates please.
{datefield} contains various dates
If 'datefield' year is less than year 2000 then change all years to 1999
taking into consideration all days that may overflow the number of days in a
normal month or any leap year issues.
I tried the following but it has errors, can anyone help.
NumberVar XDay;
NumberVar XMonth;
NumberVar XYear;
NumberVar XDaysinmonth;
NumberVar array XMontharray := [31,29,31,30,31,30,31,31,30,31,30,31];
XDay:=day({Orders.Order Date});
XMonth:=month({Orders.Order Date});
XYear:=year({Orders.Order Date});
if (XMonth=2) and (XDay=29) and ((XYear%4)>0) then (XDay:=1; XMonth:=1;
XYear:=1980);
if (XMonth>12) or (XMonth<1) then (XDay:=1; XMonth:=1; XYear:=1980);
if (XDay>XMontharray[Xmonth]) then (XDay:=1; XMonth:=1; XYear:=1980);
if (XYear<2000) then (XYear:=1999);
date(XYear, XMonth, XDay);
Looks like a sledgehammer to crack a nut, unless you know different.
Cheers
George