views:

25

answers:

2

Hi friends,

While updating a datatime column in a table from another table, i noticed that mnilliseconds value are not shown.. instead it is rounded and the value is updated to nearest seconds.

Example :

Original Value: 2008-06-26 14:06:36.643

Updated Value : 2008-06-26 14:07:00

Please help me getting the actual value including milliseconds

A: 

In SQL Server;

SELECT CAST('2008-06-26 14:06:36.643' AS SMALLDATETIME)

> 2008-06-26 14:07:00

So the destination table column is probably SMALLDATETIME (or your casting in the query).

Alex K.
i dont need 2008-06-26 14:07:00i need 2008-06-26 14:06:36.643 itself- which is not happening..its automatically rounding it to seconds..and both columns are of datetime datatype
sajad
Double check the destination column isn't SMALLDATETIME, if its not then something is coercing it to a SMALLDATETIME you will need to show your SQL.
Alex K.
HEY U R RIGHT.SORRY TO BOTHER YOU :)
sajad
A: 

In the case where you're doing a straight update of a datetime in one table with one from another table (i.e. no fiddling with the value), then it sounds like the datatype in the table being updated is not the same.

i.e. in SQL Server world, it could be that you are using SMALLDATETIME column in the table being updated, but a DATETIME field in the table being copied from. SMALLDATETIME is only accurate to the second and so would show this behaviour

AdaTheDev
Guys you are correct..its small datetime in one...i m such a stupid..:)thnx very much for pointing out
sajad