Charmed Quark Systems, Ltd. - Support Forums and Community
Week Number RTV - Printable Version

+- Charmed Quark Systems, Ltd. - Support Forums and Community (https://www.charmedquark.com/vb_forums)
+-- Forum: General Discussion (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=3)
+--- Forum: CQC Support (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=9)
+--- Thread: Week Number RTV (/showthread.php?tid=10942)



Week Number RTV - znelbok - 10-22-2019

I need to use a week number in some logic and it is not available as a runtime variable.

Is there any chance we can get it added into the system?

Until then, any ideas on how to calculate the week number from date etc.

Thanks


RE: Week Number RTV - Dean Roddey - 10-22-2019

Anything time related is tricky since it has to deal with leap this'es and that's. The week of the year isn't something available in my underlying C++ stuff either. If it doesn't have to be absolutely accurate, you can just get the Julian date for the 1st of Jan of the current year, then divide by 7. The current Julian date is available via action command but not the first of the year. You'd have to call CML to do that.

It would be something like:

1. Get current time stamp
2. Get it as individual time values
3. Leave the year value, but reset the month, day, hour, min, sec to indicate midnight the first of that year.
4. Set that back to to the time object
5. Get the Julian date from that
6. Get the current Julian date
7. Subtract the two then divide by seven