Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Date routine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date routine

    This is my date routine, you can also use it to find out how many days have elapsed between two dates (DE).

    Any improvements ?

    10:
    DATA JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER
    11:
    DATA MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
    12:
    DATA 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31

    DAYF:
    RESTORE 12
    FOR A = 1 to 12
    READ MD(A)
    NEXT A
    DD = val(left$(DT$, 2)) : MM = val(mid$(DT$, 4, 2)) : YY = val(right$(DT$, 4))
    IF YY < 1992 THEN INVDAY
    IF MM < 1 or MM > 12 THEN INVDAY
    MD(2) = MD(2) - (YY / 4 = int(YY / 4))
    IF DD < 1 or DD > MD(MM) - (YY / 4 = int(YY / 4)) THEN INVDAY
    DE = 0
    FOR Y = 1988 to YY -1
    DE = DE +365 - (Y / 4 = int(Y / 4))
    NEXT Y
    IF MM <> 1 THEN
    FOR M = 1 to MM -1
    DE = DE + MD(M)
    NEXT M
    END IF
    DE = DE + DD -1 : C = DE / 7 : D = C - int(C) : E = cint(D * 7)
    E = E +5 +7 * (E +5 > 7)
    RESTORE 11
    FOR A = 1 to E
    READ DAY$
    NEXT A
    RETURN
    INVDAY:
    DAY$ = "*" : ' INVALID DATE
    RETURN
Working...
X