04-25-2012 07:49 PM
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.
04-25-2012 07:59 PM - edited 04-25-2012 07:59 PM
How can i round a timestamp to the nearest second?
I haven't found a VI for that.
04-25-2012 08:09 PM
Round to nearest in the numeric palette. It works on timestamps just as well as floating point numbers.
04-26-2012 12:59 AM
I think it would do.
11-03-2012 08:23 AM
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,
11-03-2012 06:46 PM
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.
12-12-2013 11:59 PM
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'
12-13-2013 09:43 AM
@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