LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I programatically set the windows Date format in CVI?

Hello there,
 
Well the message subject says it all really.
I need to ensure that the date format that I retrieve from Windows is always in the English order of day/month/year regardless of how the host PC has been configured in the regional settings of control panel.
My programme runs on dedicated PCs which are used for nothing else but they are out of my control and users sometimes change the default delivery settings.
Before each time I read the date I would like to query what the date format is, change it to English order if necessary, take the readings then chnage it back if necessary. 
This will avoid the problems we have when logged data from different machines (with potentially different date formats) is pooled together in Excel for analysis and sorted on the date field.
 
Thanks
0 Kudos
Message 1 of 5
(3,476 Views)

I normally avoid using datestr exactly to exclude localizazion problems; I do prefer to format my own string for internal purposes when required instead:

#include <windows.h>

 char   date[32];
 SYSTEMTIME dh;

 GetLocalTime(&dh);
 sprintf (date, "%02d/%02d/%04d", dh.wDay, dh.wMonth, dh.wYear);

You can format your "date" string in the desired format according to your needs. Today's date will be represented as "12/06/2007" with the above code.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 5
(3,473 Views)

Hi there,

Wow! That was a quick and effective answer sir.

This is the first time I have used this forum and could not have hoped for a better response.

Many thanks

0 Kudos
Message 3 of 5
(3,472 Views)
If you haven't installed Windows SDK library or do not like to use it at all [like me Smiley Wink], you can always use GetCurrentDateTime function together with FormatDateTimeString function to build a custom date/time string.
S. Eren BALCI
IMESTEK
Message 4 of 5
(3,463 Views)
You're absolutely right, Eren: in my excuse I can tell that these function were introduced in version 8 of CVI and still I haven't started to use it extensively (I'm very conservative in this respect: until I have the impression that youth problems in new major releases aren't solved I don't use them for deployment purposes Smiley Wink )

Message Edited by Roberto Bozzolo on 06-12-2007 04:38 PM



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 5
(3,460 Views)