From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

updating Date with strings

Solved!
Go to solution

Ok what I am trying to do is update my date with three string combo boxes.  I am using a time Stamp to two string indecators for my current date and now the user has the option of adding the expiration date they can add months to the current date or days and even hours

 

how would I do this?

 

here is my current code: 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 1 of 6
(3,021 Views)
Using month as an amount of time to add in order to calc the exp date doesnt make sense because a month can be 28,29,30,31 days long.  Are you sure you want to do it this way?  How do you want to handle daylight savings and leap years?
Message Edited by jmcbee on 04-08-2009 02:37 PM
Message Edited by jmcbee on 04-08-2009 02:38 PM
Message 2 of 6
(3,007 Views)

Something like this should work.  No need to worry about the number of days in each month, just let the computer handle it.  You need to copy the hours through in the for loop to avoid losing or gaining an hour when daylight savings time starts and ends.

 

Message Edited by nathand on 04-08-2009 04:59 PM
Message 3 of 6
(2,991 Views)
Solution
Accepted by topic author Harold_Timmis
Here is an example, let me know if this works for you.  (Nathand posted while I was working that example up, it looks like his is the same as mine if not better for the daylight savings handling).
Message Edited by jmcbee on 04-08-2009 03:04 PM
Message 4 of 6
(2,986 Views)

Jmcbee - I don't think your approach handles year boundaries well (if I put in more months than the end of the year, I get a date in 1903).  On the other hand it seems to work fine with adding 366 days.  The for loop in my approach is unecessary, the right way to handle the year problem is probably this:

Message Edited by nathand on 04-09-2009 10:13 AM
0 Kudos
Message 5 of 6
(2,942 Views)
I saw that problem as well after I had posted.  I didn't test the boundry conditions before posting Smiley Surprised but I figured that between your post and mine that the poster would get the idea of how to approach the problem.
0 Kudos
Message 6 of 6
(2,939 Views)