10-13-2015 09:41 AM
I don't think that the argument that there is no "standard" way to do it means that no solution exists.
As I mentioned in the OP, java does this with a calendar object that provides a means to hide the idiosyncrocies of handling dates while also providing options to the developer of how they want to manipulate the dates.http://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html#add(int,%20int). The roll() function seems to do exactly what I want, and I what I expected adding 1 month to the date/time record would have done.
Thanks for the quick replies, everyone, even if it included a small amount of snark for the behaviour of others.
10-13-2015 10:07 AM - edited 10-13-2015 10:09 AM
Please don't think that my answer was anything other than a light-hearted comment and wasn't to be taken too seriously, if it came across that way then I apologise!
NI and the LabVIEW community produce huge amounts of code that is publicly available for use (I've even written some myself!) but I think 'expecting' them to have already written a library when there isn't a huge demand for it (given the nature of the language as an engineering tool - it's not like you're likely to write a calendar application in LabVIEW). If you do think it's a worthwhile addition - that's what the Ideas Exchange is for! 🙂
NI themselves have to decide if they want to focus their efforts on improving the core of LabVIEW (e.g. performance/stability/hardware support/low-level functions) or writing code libraries (from that core functionality - such as advanced date/time manipulation). Personally, I'd rather they did that than spend lots of time and effort on things that I might not even use and leverage the community for everything else where there is a need for it.
10-13-2015 10:31 AM
Okay attached is a quick and dirty solution. It will add the number of days that are in the current month, so the day stays the same and the month increments by one. If there is a rollover where January 30th, just add enough to land on the last day of the month in February. I think that is what you meant by truncate. It doesn't currently detect leap year but the subVI could be modified to handle that.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-13-2015 10:33 AM
no need to apologize - that is how I interpreted your comment initially and my response was in kind. I was commenting more on the general feeling of the thread, although even that feeling was very mild. This was overall quite helpful in understanding the answer to my question.
10-13-2015 10:42 AM
Thanks, Hoovah, I appreciate it.
10-13-2015 10:46 AM
Also note that Hoovah's VI doesn't take into account daylight savings time, so if you are counting on the time, it could be off an hour if you cross a time change in that month period.
10-13-2015 11:32 AM
@Matthew_Kelton wrote:
Also note that Hoovah's VI doesn't take into account daylight savings time, so if you are counting on the time, it could be off an hour if you cross a time change in that month period.
Oh thanks for mentioning that. OP really was just talking about dates so I focused on that.
If you are taking a time and adding a month, you could end up with some odd results. Adding a month to 03:00 January 28th, makes 03:00 February 28th, but then adding a month to 02:00 January 29th would make 02:00 February 29th, which is an odd case where a time can go backwards, for a month to a later date.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-13-2015 12:24 PM
Here was my take on the problem.
Worked on it during lunch without checking the thread for updates.
My version should maintain the time between standard/savings and deals with shorter months. You can use a value of -1 for the DST field in a date/time rec to ignore DST.
One case not handled is leap year.
04-27-2017 04:57 PM
Replying to an old thread, but I use this... It handles the corner cases (Leap year). This just adds 18 months as a constant.
09-15-2017 01:56 AM
Thank you.
This was exactly what I was searching for.