Support Board
Date/Time: Sat, 12 Jul 2025 02:09:21 +0000
Post From: Find time to certain Date
[2022-06-17 22:08:54] |
Trader_Rob - Posts: 18 |
Thanks for the advice! I ended up tackling this a different way by using some functions included with the SDDateTime data structure: struct Date {
int d, m, y; }; // This function returns number of // days between two given dates int getDifference(Date dt1, Date dt2) { SCDateTime Date1; SCDateTime Date2; Date1.SetDateYMD(dt1.y, dt1.m, dt1.d); Date2.SetDateYMD(dt2.y, dt2.m, dt2.d); int iDifference = 0; for (iDifference; Date1 != Date2 && iDifference < 10000; iDifference++) Date1.AddDays(1); return(iDifference); } int GetWorkdayDifference(Date dt1, Date dt2) { SCDateTime Date1; SCDateTime Date2; Date1.SetDateYMD(dt1.y, dt1.m, dt1.d); Date2.SetDateYMD(dt2.y, dt2.m, dt2.d); int iWDDifference = 0; for (int i = 0; Date1 != Date2 && i < 10000; i++) { Date1.AddDays(1); if (!Date1.IsWeekend()) iWDDifference++; } return(iWDDifference); } I hope this helps someone else in the future! I recommend doing some testing to ensure it's working as intended. I also needed the time difference, so I simply subtracted the current time from the end time. Date Time Of Last Edit: 2022-06-17 22:11:39
|