' Various Date Routines by Bill Haesslein on 2008-08-24 ' Date and Easter calculations from Marcos J. Montes ' Stripped down from original Date_Routines.iwb and modified by Brian Pugh on 2024-02-28 autodefine "off" $INCLUDE "windowssdk.inc" TYPE DateType UINT LowDW UINT HighDW ENDTYPE UNION uDT UINT64 qVar DateType dtVar ENDUNION SYSTEMTIME st FILETIME ft uDT s,e,d INT iVar,rtn ISTRING sDate[12],eDate[12],swapDate[12] openconsole 'Must be entered in Year, Month and Day order 'sDate = Start Date - eDate = End Date sDate="2000-01-01" 'Your birthday or any date you put in eDate=Date$("yyyy-MM-dd") 'Today's date ElapsedDays(sDate,eDate) PRINT print "Elapsed Days since "+sDate+":"+STR$(iVar) PRINT PRINT "Press any key to close..." DO:UNTIL INKEY$<>"" closeconsole end 'The clever stuff... SUB ElapsedDays(sDate:string,eDate:string) ' Make sure that eDate > sDate IF eDate>sDate swapDate="" else swapDate=sDate sDate=eDate eDate=swapDate endif 'First get the system time so that all the other structure members are filled GetSystemTime(st) 'Set up the SYSTEMTIME structure with the original date like so: st.wYear=val(mid$(sDate,1,4)) st.wMonth=val(mid$(sDate,6,2)) st.wDay=val(mid$(sDate,9,2)) 'Convert the system time to filetime rtn=SystemTimeToFileTime(st,ft) 'Move the FILETIME info into a UINT64 variable 'and add days using the Quad variable (this is how MS recommends doing it) s.dtVar.LowDW=ft.dwLowDateTime s.dtVar.HighDW=ft.dwHighDateTime 'First get the system time so that all the other structure members are filled GetSystemTime(st) 'Set up the SYSTEMTIME structure with the original date like so: st.wYear=val(mid$(eDate,1,4)) st.wMonth=val(mid$(eDate,6,2)) st.wDay=val(mid$(eDate,9,2)) 'Convert the system time to filetime rtn=SystemTimeToFileTime(st,ft) 'Move the FILETIME info into a UINT64 variable 'and add days using the Quad variable (this is how MS recommends doing it) e.dtVar.LowDW=ft.dwLowDateTime e.dtVar.HighDW=ft.dwHighDateTime d.qVar=e.qVar-s.qVar iVar=d.qVar/(24*60*60*10000000) return iVar 'iVar contains number of Elapsed Days endsub