Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Date Related Commands Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
' This example uses the DATEVALUE function to convert a string to a date
' value. A calculation is then made that tells you the date of two weeks
' before and after your birth. Date information is displayed using the
' WEEKDAY, DAY, MONTH, and YEAR functions.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
CLS ' Clear the screen
OPTION BASE 1
DIM DayOfWeek(7) AS STRING
DIM MonthOfYear(12) AS STRING
FOR I = 1 TO 7 ' Initialize the arrays
READ DayOfWeek(I)
NEXT I
FOR I = 1 TO 12
READ MonthOfYear(I)
NEXT I
INPUT "Enter your birthdate as MM/DD/YYYY "; Birthdate$
' Convert input date to numbers and create a complete date string.
BDateVal = DATEVALUE(Birthdate$) ' Get the unique date value
BDay$ = DayOfWeek$(WEEKDAY(BDateVal)) + " " + MonthOfYear$(MONTH(BDateVal))
BDay$ = BDay$ + STR$(DAY(BDateVal)) + "," + STR$(YEAR(BDateVal))
EDateVal = BDateVal - 14 ' Calculate a date 14 days earlier
' Put the date string together.
EDay$ = DayOfWeek$(WEEKDAY(EDateVal)) + " " + MonthOfYear$(MONTH(EDateVal))
EDay$ = EDay$ + STR$(DAY(EDateVal)) + "," + STR$(YEAR(EDateVal))
LDateVal = BDateVal + 14 ' Calculate a date 14 days later
' Put the date string together.
LDay$ = DayOfWeek$(WEEKDAY(LDateVal)) + " " + MonthOfYear$(MONTH(LDateVal))
LDay$ = LDay$ + STR$(DAY(LDateVal)) + "," + STR$(YEAR(LDateVal))
PRINT "You were born on "; BDay$; "." ' Display the results
PRINT
PRINT "What you may not have been able to immediately calculate was:"
PRINT
PRINT "Two weeks before your birth was "; EDay$; "."
PRINT "Two weeks after your birth was "; LDay$; "."
END
DATA "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"
DATA "Friday", "Saturday"
DATA "January", "February", "March", "April", "May", "June", "July"
DATA "August", "September", "October", "November", "December"