04-08-2013 04:59 AM
Hi guys,
I am building a system where I am required to display results for the week so far, starting on Sunday. To do this I need to get a timestamp of what the date was at midnight on the last Sunday, and I am having trouble getting it right.
If possible I need it to work based off the system calendar, rather than doing some crazy 'if it's this month there are x no of days if the week spans two months' etc. (if that makes sense!)
I have been trying to use a timing control included in labview and changing the "Day of week" and "day of year" settings, but these do not seem to be making any difference to my timestamp as it is still taking the values from the "day of month" setting.
I was wondering if anyone on here can spot something I have missed?
I have attached a screenshot of the code I have tried to use, and a copy of the control I am using (it is a LabVIEW control that is included, but I have changed the name of it so I could have a copy in my local folder)
Solved! Go to Solution.
04-08-2013 05:14 AM
The day of month has a special behavior which allows it to overflow and change the time. I don't think it was put in on purpose.
What you can do is to repeatedly subtract one day from now until you get to Sunday, like so (the d is a unit label):
04-08-2013 05:27 AM
Thank You!
I had to do a bit of modifying just to get it to midnight but this was basically just what I was looking for.
So simple - and yet it never even crossed my mind!
04-08-2013 05:32 AM
You will probably also want to account for the case where the code is run on a Sunday.
04-08-2013 06:09 AM