LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timestamp with milliseconds to double

Solved!
Go to solution

I need to get my formatted time stamp (which includes down to the millisecond) into a double format. I've been using scan from string. No matter what formatting I use, the double number is always truncated and only displays a reolution of a tenth of  a second. 

 

I need my date/time string in DBL format becuase I need to append it to an array of other DBL numbers which is being written to a .csv file. So it can't be in string format (unless theres some way to write both to a .csv file)

 

What can I do to get the respresentaion correct? 

 

qqqqq.gif

0 Kudos
Message 1 of 11
(7,068 Views)

in your example, there is no reason to even go to a string.  Just use the To Double coercion node.

 

I'll try to play around with this to see if I can find something with the string formatting.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 11
(7,058 Views)

THanks criossrulz, you're right, I just used a to double conversion node/.

 

Problem solved, my issue is that in my write to spreadsheet file vi, I had the wrong formatting parameter. 

0 Kudos
Message 3 of 11
(7,055 Views)

Not sure why you are converting to a string and then a double.

 

Why not covert to a double then format the double as a string?

 

DateTime to 10.6f.png

 

Guess I was to slow... Thats what happens when you get old...


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 4 of 11
(7,052 Views)

I need it as a double because I need to append it to an array of DBL which is being written to a .csv file.

 

And I need the date/time stamp in the format I specified. WHen I convert the string to double, it loses its resolution (which is down to 1e-6 seconds) see below. 

 

ssss.gif

0 Kudos
Message 5 of 11
(7,042 Views)

I actually can't just coerce to double because I need the timestamp formatted in the way I specified in "format date/time string"

0 Kudos
Message 6 of 11
(7,032 Views)

@Snow_In_Tehran wrote:

I need it as a double because I need to append it to an array of DBL which is being written to a .csv file.

 

And I need the date/time stamp in the format I specified. WHen I convert the string to double, it loses its resolution (which is down to 1e-6 seconds) see below. 

 

ssss.gif


You just have a display issue here.  Change the data format of your numeric to be floating point with a high number of digits of precision and you will see that your data is there.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 11
(7,028 Views)

Thanks, that takes care of displaying it on the front panel. However, how to I get it so that such a representation is passed out of the function to I can write it to my data file?

 

The DBL that it outputs is still only to a tenth of a second format.

0 Kudos
Message 8 of 11
(7,018 Views)
Solution
Accepted by topic author Snow_In_Tehran

@Snow_In_Tehran wrote:

Thanks, that takes care of displaying it on the front panel. However, how to I get it so that such a representation is passed out of the function to I can write it to my data file?

 

The DBL that it outputs is still only to a tenth of a second format.


Well that completely depends on the format string you are using for when you are creating your CSV.  You probably want something like "%.6f" for you format.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 11
(7,012 Views)

I've tried that and every type of formatting and it still gives me that precision.

 

Interestingly, when I do %f.6  as opposed to %.6f, I get the resolution. However, there is a .6 appended to every number in the data file! Any idea how I can get that out? Now I'm getting the precision I want but have that weird character in there. 

 

 

gggg.gif

 

 

gggg.gif

0 Kudos
Message 10 of 11
(6,992 Views)