Altering dates 
Author Message
 Altering dates

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;
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.


Sat, 29 Jun 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Altering Date & Time

2. alter directory modification date

3. Altering File Date and Time

4. VB - Altering File Date and Times

5. Date parameters altered when scheduling thru APS - Seagate Info

6. ALTER COLUMN setting default to Date()

7. alter directory modification date

8. Date - date = date

9. Compare date in form with date/time in form with date/time in database

10. Dates dates dates

11. Dates, Dates, & More Dates

12. altering table field size via VB


Powered by phpBB® Forum Software