NI Home > Community > NI Discussion Forums


Showing results for 
Search instead for 
Do you mean 
Posts: 50
0 Kudos
Accepted Solution

check if date exists in LabVIEW

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!
Proven Zealot
Posts: 5,371
0 Kudos

Re: check if date exists in LabVIEW

Hi noxus,
you can use the Scan from String function. If you get en error, then the date is wrong.

Knight of NI
Posts: 28,953

Re: check if date exists in LabVIEW

[ Edited ]
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

LabVIEW Champion . Do more with less code and in less time .

Posts: 50
0 Kudos

Re: check if date exists in LabVIEW

Great ... that should do the trick!

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


Posts: 48
0 Kudos

Re: check if date exists in LabVIEW

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.