Quote from: Brian on November 22, 2023, 08:09:25 AMgil: Couldn't convert your code to IWB - my brain wasn't in gear
$INCLUDE "windowssdk.inc"
AUTODEFINE "off"
DEF wdate:STRING
wdate=DATE$("yyyy-MM-dd")
wdate=datemath(wdate,1)
END
SUB DateMath(id:STRING,diff:INT),STRING
'======================================
DEF yyyy,mm,dd:INT
TYPE DateType
UINT LowDW
UINT HighDW
ENDTYPE
UNION uDT
UINT64 qVar
DateType dtVar
ENDUNION
SYSTEMTIME st
FILETIME ft
uDT u
INT rtn
'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$(id,1,4))
st.wMonth=VAL(MID$(id,6,2))
st.wDay=VAL(MID$(id,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 M$ recommends doing it)
u.dtVar.LowDW=ft.dwLowDateTime
u.dtVar.HighDW=ft.dwHighDateTime
'Add days using the Quad variable - 1 day in nano seconds 24 * 60 * 60 * 10000000
u.qVar+=((24*60*60*10000000)*diff) ' <---- diff days
ft.dwLowDateTime=u.dtVar.LowDW
ft.dwHighDateTime=u.dtVar.HighDW
'Convert the file time to system time
rtn=FileTimeToSystemTime(ft,st)
'Now your new date will be in the SYSTEMTIME structure members
yyyy=st.wYear
mm=st.wMonth
dd=st.wDay
RETURN USING("0####&0##&0##",yyyy,"-",mm,"-",dd)
ENDSUB