NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
noxus
Posts: 46
0 Kudos

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
MikeS81
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.

Mike
Knight of NI
altenbach
Posts: 22,876

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 . Oh, by the way, I work for peanutsKudos .

Member
noxus
Posts: 46
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.

 

Member
JimboH
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.

 

FixDate.png

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page