LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Error using FormatDateTimeString in Vista

I use the FormatDateTimeString function to return the weekday or week of the year (%w or %U specifiers).  When compiling/running in XP I get the proper information, but compiling/running in Vista gives me an error.  Tuesday is reported to be the first day of the week?
0 Kudos
Message 1 of 5
(3,388 Views)

Hello Mande,

 

Could you post a small snippet of code that demonstrates the behavior you are seeing on Vista so that I can try and duplicate this?

With warm regards,

David D.
0 Kudos
Message 2 of 5
(3,369 Views)

Hello Mande,

 

I just ran a quick test on my Vista machine, and %w returned 2 as the day of the week (convenient that today happened to be Tuesday... Smiley Happy   )   The piece of code that I used is as follows:

 

#define DATETIME_FORMATSTRING "%I:%M%p %w, %B %d, %Y"

 

...

 

static double currDateTime;
static int bufferLen;
static char *dateTimeBuffer = NULL;
switch (event)

GetCurrentDateTime (&currDateTime);
bufferLen = FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING, NULL, 0);
dateTimeBuffer = malloc (bufferLen + 1);
FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING, dateTimeBuffer, bufferLen + 1 );
SetCtrlAttribute(panelHandle, PANEL_TEXTMSG, ATTR_CTRL_VAL, dateTimeBuffer);
free(dateTimeBuffer);

 

Working format string 

 

If you could perhaps post a small snippet of code that does not seem to be working for you, I would be happy to have a look at it.

 

NickB

National Instruments 

Message Edited by nickb on 08-26-2008 08:47 AM
0 Kudos
Message 3 of 5
(3,347 Views)

Thank you for your test, I did not get email about the response so I hadn't checked it until now.

 

I ran your code on my machine and I was given the response below.  Today is Tuesday but I was given the day as zero.

 

 Time Test: 05:04PM 0, September 02, 2008

 

 

My CVI version returns Version 8.0.0 (273)

 

Thanks.

0 Kudos
Message 4 of 5
(3,306 Views)

Hello Mande,

 

From this KnowledgeBase article here we see that CVI 8.0.0 is not supported on Windows Vista. One thing you can try that might work is to install the latest version of the run time from our website (8.5.1, link). As I mentioned, I am not positive that this will work but it's a possible solution that does not take long to try and you should have no problems since the run time is backwards compatible.

With warm regards,

David D.
0 Kudos
Message 5 of 5
(3,290 Views)