Test Code for AddToDate() Note that the test for adding days and weeks and most of the years is commented out.
Note that the "interval" word is not case-sensitive and it works with or without a final S, i.e., Day, Days, day, DAYS will all work.
// ================== TEST CODE =====================
var NewDate as Date // AddToDate(OldDate as Date, AddWhat as String, AmountToAdd as Int) as Date
// Test Add To Date Subroutine TATD(vDate as Date, vInterval as String, vAmt as Int) Writeln("===================") Writeln(vDate) Writeln(vInterval) Writeln(vAmt) Writeln(AddToDate(vDate, vInterval, vAmt)) End Subroutine
OpenSlate()
/*
Writeln("DAYS AND WEEKS") TATD("2006/07/09", "days", 5) // = 2006/07/14 TATD("2007/05/02", "weeks", 6) // = 2007/06/13
TATD("2016/08/09", "days", 15) // = 2016/08/24 TATD("2027/11/06", "weeks", 3) // = 2027/11/27
TATD("2026/12/12", "days", 14) // = 2026/12/26 TATD("2017/10/16", "weeks", 8) // = 2017/12/11
TATD("1992/02/25", "days", 14) // = 1992/03/10 TATD("1980/11/02", "weeks", 28) // = 1981/05/17
TATD("1946/11/09", "days", 85) // = 1947/02/02 TATD("2014/10/06", "week", 3) // = 2014/10/27
TATD("2038/11/12", "days", 34) // = 2038/12/16 TATD("2007/10/16", "weeks", 8) // = 2007/12/11
// =================================
Writeln("") Writeln("ADD MONTHS AND YEARS")
TATD("2006/07/09", "months", 5) // = 2007/12/09 TATD("2007/05/02", "years", 6) // = 2013/05/02
TATD("2016/08/09", "months", 15) // = 2017/11/09 TATD("2027/11/06", "years", 3) // = 2030/11/06
TATD("2026/12/12", "months", 14) // = 2028/02/12 TATD("2017/10/16", "years", 8) // = 2025/10/16
TATD("1992/12/09", "months", 74) // = 1999/02/09 TATD("1980/11/02", "years", 28) // = 2008/11/02
TATD("1946/11/09", "months", 85) // = 1954/12/09 TATD("2014/10/06", "years", 3) // = 2017/10/06
TATD("2038/11/12", "months", 34) // = 2041/09/12 TATD("2007/10/16", "years", 8) // = 2015/10/16
*/
// =================================
Writeln("") Writeln("") Writeln("=========== SUBTRACT MONTHS AND YEARS ==============") Writeln("") Writeln("")
TATD("2006/07/09", "months", -5) // = 2006/02/09 Writeln("2006/02/09 <==")
TATD("2006/07/09", "months", -7) // = 2005/12/09 Writeln("2005/12/09 <==")
TATD("2016/08/09", "months", -15) // = 2015/05/09 Writeln("2015/05/09 <==")
TATD("2027/11/06", "years", -3) // = 2024/11/06
TATD("2026/12/12", "months", -14) // = 2025/10/12 Writeln("2025/10/12 <==")
TATD("2017/10/16", "months", -10) // = 2016/12/16
TATD("1992/12/09", "months", -74) // = 1986/10/09 Writeln("1986/10/09 <== 6Y 2M")
TATD("1980/11/02", "months", -35) // = 1977/12/02 Writeln("")
TATD("1946/11/09", "months", -85) // = 1939/10/09 Writeln("1939/10/09 <== 7Y 1M")
TATD("2014/10/06", "years", -3) // = 2011/10/06
TATD("2038/11/12", "months", -34) // = 2036/01/12 Writeln("2036/01/12 <== 2Y 10M")
TATD("2007/10/16", "years", -8) // = 1999/10/16
|