LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Variant To Data" VI converts date/time inaccurately.

Solved!
Go to solution

Why not just round the resulting timestamp to the nearest second?

 

And if you need to store milliseconds in the database, since the database can't handle that resolution, store the fractional seconds in a separate field that you add to the timestamp once it has been rounded to the second.

0 Kudos
Message 11 of 18
(1,455 Views)

How can i round a timestamp to the nearest second?

I haven't found a VI for that.

0 Kudos
Message 12 of 18
(1,454 Views)

Round to nearest in the numeric palette.  It works on timestamps just as well as floating point numbers.

0 Kudos
Message 13 of 18
(1,449 Views)

I think it would do.

0 Kudos
Message 14 of 18
(1,439 Views)

Hi,

 

I have a similar problem .I am inserting timestamp values to an SQL database. The problem is when I make the conversion To Variant before insert the data I am loosing the millisecond value of the timestamp.

 

For example: Timestamp value = 6:48:39.578 AM 10/21/2010 but after the To variant function I get 6:48:39.000 AM 10/21/2010

 

Thanks,

0 Kudos
Message 15 of 18
(1,382 Views)

Losing NOT "loosing".

 

As early posts said, the database won't take millisecond values.  To round down to the nearest second, and store the millisecond part of the time in a separate field.

0 Kudos
Message 16 of 18
(1,375 Views)

I have a similar problem as TinoMK.

 

The SQL Database does support time in milliseconds.

But when i convert the data from'Date/Time' to a Variant that can be read by DB Tools VI, i loose out on all the info about milli seconds.

 

See attached Files - 

File 1 - Milliseconds allowed in SQL DB

File 2- My Prog

Details - The program tries to capture value from a sensor (here the counter value 'i'), along with the current dat/time. The data to be recorded in a SQL Database (Time + SensorVal) is made into a cluster first, then, cluster to variant.

 

The descrepancy arises in the date/time string in 'output cluster' (which has milliseconds data) vs 'variant' (doesn't have milliseconds data).

 

So my point here is, even before the data is sent to the database. The information about 'milli seconds' is lost when we convert the cluster to variant.

 

Please provide some info/solution to this.

 

File 3 - Screent shot of 'output cluster' & 'variant'

Download All
0 Kudos
Message 17 of 18
(1,313 Views)

@NishantPatel wrote:

I have a similar problem as @TinoMK.

 

The SQL Database does support time in milliseconds.

But when i convert the data from'Date/Time' to a Variant that can be read by DB Tools VI, i loose out on all the info about milli seconds.

 

See attached Files - 

File 1 - Milliseconds allowed in SQL DB

File 2- My Prog

Details - The program tries to capture value from a sensor (here the counter value 'i'), along with the current dat/time. The data to be recorded in a SQL Database (Time + SensorVal) is made into a cluster first, then, cluster to variant.

 

The descrepancy arises in the date/time string in 'output cluster' (which has milliseconds data) vs 'variant' (doesn't have milliseconds data).

 

So my point here is, even before the data is sent to the database. The information about 'milli seconds' is lost when we convert the cluster to variant.

 

Please provide some info/solution to this.

 

File 3 - Screent shot of 'output cluster' & 'variant'


The DB Tools cut milliseconds as not all databases handles seconds. In this case it's easier to format the timestamp as a string (with milliseconds) and send that, it's basically what the DB timestamp does anyway.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 18 of 18
(1,283 Views)