June 13, 2008 at 9:53 am
Hi,
I have a simple SQL queries, and I do not understand why there are some time-partion values of datetime-typed column "Dates" do not match with what I expect in INSERT statements.
Thank you for your help.
declare @t table (clientid int, Unitbalance numeric(21,0), Dates datetime)
insert into @t values (123, 999, '1 jan 2008 12:00:01:001')
insert into @t values (456, 888, '1 jan 2008 12:00:01:006')
insert into @t values (456, 777, '1 jan 2008 12:00:01:007')
insert into @t values (789, 222, '1 jan 2008 12:00:01:008')
insert into @t values (789, 333, '1 jan 2008 12:00:01:009')
insert into @t values (123, 999, '1 jan 2008 12:00:01:010')
insert into @t values (123, 111, '1 jan 2008 12:00:01:011')
-- work
select * from @t
And there are some time-portion values in the datetime-typed "Dates" column do not match with previpusly input using INSERT
clientid Unitbalance Dates
----------- ----------------------- ------------------------------------------------------
123 999 2008-01-01 12:00:01.000
456 888 2008-01-01 12:00:01.007
456 777 2008-01-01 12:00:01.007
789 222 2008-01-01 12:00:01.007
789 333 2008-01-01 12:00:01.010
123 999 2008-01-01 12:00:01.010
123 111 2008-01-01 12:00:01.010
June 13, 2008 at 2:25 pm
Interesting one. The reason could be due to the rounding off. BOL says:
"datetime values are rounded to increments of .000, .003, or .007 seconds"
June 13, 2008 at 9:31 pm
Correct... the DATETIME datatype has a resolution of 3.3 milliseconds.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy