LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Windows Short date and time formats from Labview .

Hi .
I am using Labview to retrieve some data from an Access database. In the
Access database the date time field is in the format I need to use
02-Jan-2001 12:00:00. However if the windows regional settings are set to
something else. The database date time stamp is returned in the system date
time format. Has anyone got a VI that will set the Windows System date and
time format?

Regards
Leo
0 Kudos
Message 1 of 3
(3,704 Views)
Yes, I've run into this too, while using the SQL Toolkit to manipulate an Access 97 db. The problem arises when you retrieve a date/time field - which must be returned as a string. You want to parse the string so you can convert it back into a LabVIEW floating-point numeric date/time, so you can do date/time math. But you can't do the Scan from String reliably if the Windows Regional Settings are changed, which any user can do.
For this, I wrote a couple of VIs which call the Windows 'SetLocaleInfo' API function from kernel32.dll and force the date/time picture into the ODBC-semi-standard format of 'yyyy-mm-dd hh:mm:ss'. I've attached a LV5.1 LLB which ought to help.

Hope the file attaching process works - haven't done this from the DevZone website be
fore. If it doesn't show up, I'll re-send to Leo's e-mail.
David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
Message 2 of 3
(3,704 Views)
I just made a VI (in LabVIEW 6i) that gets or sets the system time format using the Get- and SetLocaleInfo Win32 API function calls. A 'Set?' boolean controls whether to read or set the date format. I preset the date format to 'dd-MMM-yyyy hh:mm:ss' to match the 02-Jan-2001 12:00:00 you showed on your posted question.
Hope this helps!
John Wilson
Sanders Engineering & Analytical Services, Inc.
Mobile, Alabama
johnwilson@pctechnician.net
251-633-4120
Message 3 of 3
(3,704 Views)