Wrote a set of functions for you.
The time returned in seconds, while representative of originating from Jan 1 1970, cannot be used in conjunction with existing date functions in other languages because these function do not account for leap seconds as others are based on the unix epoch.
REM ================================================
REM Title: Date Functions
REM Author: Phaelax
REM Date: Apr 4, 2011
REM ================================================
curDate = getCurDateInSeconds()
newDate = addDays(curDate, 9)
myDate = getDateInSeconds(1983, 1, 19)
ageInSec = diffDates(curDate, myDate)
print "Today is: ",formatDate$(curDate)
print
print ".... Adding 9 days to current date ...."
print
print "New date is: ",formatDate$(newDate)
print
print ".... Subtract my birth date (1983-1-19) from current date ...."
print
print "I am ", getNumOfYears(ageInSec), " years old."
print "That is ", getNumOfMonths(ageInSec), " months in baby age."
print "Or, ", getNumOfDays(ageInSec), " days old."
wait key
end
REM Formats a date in seconds into a readable string
function formatDate$(dateInSeconds)
year = getYear(dateInSeconds)
month = getMonth(dateInSeconds)
day = getDay(dateInSeconds)
select month
case 1 : s$ = "Jan " : endcase
case 2 : s$ = "Feb " : endcase
case 3 : s$ = "Mar " : endcase
case 4 : s$ = "Apr " : endcase
case 5 : s$ = "May " : endcase
case 6 : s$ = "Jun " : endcase
case 7 : s$ = "Jul " : endcase
case 8 : s$ = "Aug " : endcase
case 9 : s$ = "Sep " : endcase
case 10 : s$ = "Oct " : endcase
case 11 : s$ = "Nov " : endcase
case 12 : s$ = "Dec " : endcase
endselect
s$ = s$ + str$(day) + ", " + str$(year)
endfunction s$
REM Returns the current date in seconds
function getCurDateInSeconds()
d$ = get date$()
day = val(left$(d$, 2))
month = val(right$(left$(d$, 5), 2))
year = val("20"+right$(d$, 2))
s = getDateInSeconds(year, month, day)
endfunction s
REM Convert specified date into seconds from unix epoch
function getDateInSeconds(year, month, day)
seconds = (year-1970)*31556926 + month*2629743 + day*86400
endfunction seconds
REM Subtrats the second date from the first date
REM Returns in seconds
function diffDates(dateInSeconds1, dateInSeconds2)
s = dateInSeconds1 - dateInSeconds2
endfunction s
function diffDatesX(year1, month1, day1, year2, month2, day2)
s1 = getDateInSeconds(year1, month1, day1)
s2 = getDateInSeconds(year2, month2, day2)
s = s1 - s2
endfunction s
REM Add years, months, or days to specified time
function addYear(dateInSeconds, numYears)
dateInSeconds = dateInSeconds + numYears*31556926
endfunction dateInSeconds
function addMonths(dateInSeconds, numMonths)
dateInSeconds = dateInSeconds + numMonths*2629743
endfunction dateInSeconds
function addDays(dateInSeconds, numDays)
dateInSeconds = dateInSeconds + numDays*86400
endfunction dateInSeconds
REM Subtract years, months, or days from specified time
function subYear(dateInSeconds, numYears)
dateInSeconds = dateInSeconds - numYears*31556926
endfunction dateInSeconds
function subMonths(dateInSeconds, numMonths)
dateInSeconds = dateInSeconds - numMonths*2629743
endfunction dateInSeconds
function subDays(dateInSeconds, numDays)
dateInSeconds = dateInSeconds - numDays*86400
endfunction dateInSeconds
REM Retrieve the year, month, or day from a time represented in seconds
function getYear(seconds)
years = (seconds / 31556926) + 1970
endfunction years
function getMonth(seconds)
years = seconds / 31556926 : seconds = seconds - (years*31556926)
month = seconds / 2629743
endfunction month
function getDay(seconds)
years = seconds / 31556926 : seconds = seconds - (years*31556926)
month = seconds / 2629743 : seconds = seconds - (month*2629743)
day = seconds / 86400
endfunction day
REM Returns the number of years, months, or days from the specified
REM amount of time in seconds
function getNumOfYears(seconds)
y = seconds / 31556926
endfunction y
function getNumOfMonths(seconds)
m = seconds / 2629743
endfunction m
function getNumOfDays(seconds)
d = seconds / 86400
endfunction d
The Internet: Where men are men, women are men, and children are federal agents