LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format Time Stamp String for excel error

Hi all,

 

I am currently trying to format the time stamp from labview to excel, in an excel recognizable format.  Ive attached a photo of that part of the vi.  The time stamp is formated correctly when it leaves the format time stamp block and after it leaves the build array block, but when it is written to excel file it is formated in what looks like a standard format and excel does not recognize this as a time stamp.

 

Any ideas to fix the issue?

 

Thanks



-Matt
0 Kudos
Message 1 of 8
(3,532 Views)

Excel has cell formatting that a standard text file won't.  When you write to a text file it doesn't being along things that Excel may have in a cell like the type of information in the cell.

 

For example in Excel you can format a cel to display currency where it will put a dollar symbol at the front, put a comma every three zeros, and a decimal place followed by two zeros.

 

In the text file you write you wrote text not time.  Even when you write numbers, you actually write text because that is all a CSV file is.  When Excel opens it it does it knows there is no formatting, but it tries to be smart and says if the whole cell is a number and no alpha characters, format it as a number, otherwise it is a string.  

 

In short there is no way to convince Excel that the string you write should be interpreted as time, without extra things like ActiveX.

0 Kudos
Message 2 of 8
(3,520 Views)

hooovahh,

 

that makes complete sense.  Im assuming it has been done before using active x though, do you happen to have an example?



-Matt
0 Kudos
Message 3 of 8
(3,515 Views)

I might have to post my code to give you a better idea, but is it possible to write tame stamps to excel, using the easy excel blocks?



-Matt
0 Kudos
Message 4 of 8
(3,511 Views)

The Example Finder has a few ActiveX examples I think one uses Excel.

 

Also if you have the Report Generation Toolkit I think this is what you need

 

http://digital.ni.com/public.nsf/allkb/38D7104644E0F7A5862578B1001A86C5

 

It sets the cell format to be how you want.  The default for a timestamp is "m/d/yyyy h:mm".

 

BUT I just think I have an easier solution.  The problem is it correctly detects that this is a time stamp, but the cell format is incorrect.  If we convince it that it is a string it will look right and I assume that's all that matters.  So add a space to the front of your time, so have the format be " %Y-%m-%d %H:%M:%S" (notice the space) and I think it will look the way you want because Excel thinks it is a string.

Message 5 of 8
(3,507 Views)

So putting the space in front of the string format does work to get the correct formatted time stamp, but you were correct that excel does not recognize the time stamp, i may try to follow the easy excel set up, but i have to rearrange a lot.  Do you have any useful tutorials or examples for the easy excel?



-Matt
0 Kudos
Message 6 of 8
(3,499 Views)

I'd recommend any examples that are in the Example Finder.  You can filter based on toolkits installed and you should find one for report generation.

0 Kudos
Message 7 of 8
(3,495 Views)

I will try that. Thanks for the help.

 

I dont know your knowledge with excel, but if i change the cell format to time in excel, it still doesnt recognize it as time and that seems odd to me.  Possibly this is not the right format for excel?



-Matt
0 Kudos
Message 8 of 8
(3,491 Views)