LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

check if date exists in LabVIEW

Solved!
Go to solution
A simple question:
 
I cannot use the Time Stamp Control due to some special user interface requirements.
The user is forced to enter date and time information via some sort of a keypad. (no mouse available)
I have a year, month and day field.
 
How can I best check if the entered date is a valid date. (taking everything into account such as leap year, ...)?
 
Checking the time fields is easy.
I know how to check for a valid date in C++ so I could create a DLL but I was wondering if there is also a pure LabVIEW solution.
Thanks for the help!
0 Kudos
Message 1 of 8
(5,490 Views)
Hi noxus,
you can use the Scan from String function. If you get en error, then the date is wrong.

Mike
0 Kudos
Message 2 of 8
(5,470 Views)
Solution
Accepted by noxus
You can form a "date time record" cluster and see if it produces a valid timestamp. It will validate the month (1..12) and year, The day will wrap, so if you enter 2-29-2008 you'll get 2-29-2008, but if you enter 2-29-2007 you'll get 3-1-2007. See if it works for your purpose.
 
 


Message Edited by altenbach on 06-18-2008 10:13 PM
Message 3 of 8
(5,466 Views)

Great ... that should do the trick!

Thanks for the solution - now I don't need the extra DLL.

 

0 Kudos
Message 4 of 8
(5,450 Views)

Sorry to bring up an old thread. The code helped. At least in LV 2009 an input of day 0 shifts the month back to the last day of the previous month. I don't like that behavior so I added an extra check for this.

 

FixDate.png

0 Kudos
Message 5 of 8
(5,101 Views)

Hello,

 

Your solution is not completed.

 

I wanted  to check if a date (YYMMDD) is valid or not . I minds that have more control than check that the day is comprised between 0-31 and month between 0 and 12.  I wanted to advoid for example that the operator introduce a wrong barcode (ex 31 feb 2015 = 150231).

 

Thanks for your helps

 

Marc

0 Kudos
Message 6 of 8
(4,802 Views)
Of course it is complete in reference to the original question. You are now just adding more requirements. 🙂
You can compare the input date with the date obtained from the processed value to see if they are equal.
0 Kudos
Message 7 of 8
(4,772 Views)

that's true and the solution is so evident... Thanks

0 Kudos
Message 8 of 8
(4,739 Views)