Showing results for 
Search instead for 
Did you mean: 
Reply

check if date exists in LabVIEW

Solved!
Go to 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!
0 Kudos
Message 1 of 8 (2,068 Views)
Reply
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.

Mike
0 Kudos
Message 2 of 8 (2,048 Views)
Reply
0 Kudos
Solution
Accepted by topic author noxus
‎08-27-2015 06:09 PM

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
Message 3 of 8 (2,044 Views)

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.

 

0 Kudos
Message 4 of 8 (2,028 Views)
Reply
0 Kudos
Highlighted

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.

 

FixDate.png

0 Kudos
Message 5 of 8 (1,679 Views)
Reply
0 Kudos

Re: check if date exists in LabVIEW

[ Edited ]

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 (1,380 Views)
Reply
0 Kudos

Re: check if date exists in LabVIEW

Of course it is complete in reference to the original question. You are now just adding more requirements. Smiley Happy
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 (1,350 Views)
Reply
0 Kudos

Re: check if date exists in LabVIEW

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

0 Kudos
Message 8 of 8 (1,317 Views)
Reply
0 Kudos