473,467 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Weird millisecond part of datetime data in SQL Server 2000

Execute following T-SQL within Queary Analyzer of SQL Server 2000:

=======================================
DECLARE @dTest DATETIME

SET @dTest='2001-1-1 1:1:1:991'
SELECT @dTest

SET @dTest='2001-1-1 1:1:1:997'
SELECT @dTest

SET @dTest='2001-1-1 1:1:1:999'
SELECT @dTest
=======================================

You get what?
This is my result which is weird:

2001-01-01 01:01:01.990
2001-01-01 01:01:01.997
2001-01-01 01:01:02.000

Then what's the reason of this weird problem?

Dec 18 '06 #1
3 5439

aling wrote:
Execute following T-SQL within Queary Analyzer of SQL Server 2000:

=======================================
DECLARE @dTest DATETIME

SET @dTest='2001-1-1 1:1:1:991'
SELECT @dTest

SET @dTest='2001-1-1 1:1:1:997'
SELECT @dTest

SET @dTest='2001-1-1 1:1:1:999'
SELECT @dTest
=======================================

You get what?
This is my result which is weird:

2001-01-01 01:01:01.990
2001-01-01 01:01:01.997
2001-01-01 01:01:02.000

Then what's the reason of this weird problem?
DATETIME has accuracy of 3 ticks - it does not support 999 ms. The
value is rounded to the nearest supported value.

-----------------------
Alex Kuznetsov
http://sqlserver-tips.blogspot.com/
http://sqlserver-puzzles.blogspot.com/

Dec 18 '06 #2
Alex Kuznetsov wrote:
aling wrote:
>Execute following T-SQL within Queary Analyzer of SQL Server 2000:

=======================================
DECLARE @dTest DATETIME

SET @dTest='2001-1-1 1:1:1:991'
SELECT @dTest

SET @dTest='2001-1-1 1:1:1:997'
SELECT @dTest

SET @dTest='2001-1-1 1:1:1:999'
SELECT @dTest
=======================================

You get what?
This is my result which is weird:

2001-01-01 01:01:01.990
2001-01-01 01:01:01.997
2001-01-01 01:01:02.000

Then what's the reason of this weird problem?

DATETIME has accuracy of 3 ticks - it does not support 999 ms. The
value is rounded to the nearest supported value.
Out of curiosity, what are the supported values? The behavior
reported above (991 rounded down, 997 left alone, 999 rounded up)
is still weird - it suggests that the supported values are 3 ticks
apart, but with a 1-tick jump somewhere in the 991-997 range.
Dec 18 '06 #3
Ed Murphy wrote:
>
Alex Kuznetsov wrote:
aling wrote:
Execute following T-SQL within Queary Analyzer of SQL Server 2000:

=======================================
DECLARE @dTest DATETIME

SET @dTest='2001-1-1 1:1:1:991'
SELECT @dTest

SET @dTest='2001-1-1 1:1:1:997'
SELECT @dTest

SET @dTest='2001-1-1 1:1:1:999'
SELECT @dTest
=======================================

You get what?
This is my result which is weird:

2001-01-01 01:01:01.990
2001-01-01 01:01:01.997
2001-01-01 01:01:02.000

Then what's the reason of this weird problem?
DATETIME has accuracy of 3 ticks - it does not support 999 ms. The
value is rounded to the nearest supported value.

Out of curiosity, what are the supported values? The behavior
reported above (991 rounded down, 997 left alone, 999 rounded up)
is still weird - it suggests that the supported values are 3 ticks
apart, but with a 1-tick jump somewhere in the 991-997 range.
It's all in BOL.

"datetime values are rounded to increments of .000, .003, or .007
seconds"

See
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/9bd1cc5b-227b-4032-95d6-7581ddcc9924.htm
for example 'rounding' with data type datetime and smalldatetime.

Gert-Jan
Dec 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Wolfgang Kaml | last post by:
Hello All, I have been researching newsgroups and knowledgebase all morning and not found a solution that would solve the problem I have. I am having an ASP or ASPX web page that implement a...
2
by: Edward | last post by:
SQL Server 2000 Enterprise Edition Access 2000 Front End One of our clients has recently been experiencing problems with an app that has run satisfactorily (though slowly) for some time. To...
8
by: Edward | last post by:
SQL Server 7.0 The following SQL: SELECT TOP 100 PERCENT fldTSRID, fldDateEntered FROM tblTSRs WITH (NOLOCK) WHERE ((fldDateEntered >= CONVERT(DATETIME, '2003-11-21 00:00:00', 102)) AND...
1
by: js | last post by:
I have tables with columns that stores datetime data in int format on SQL server 2000. For example, the datetime for '4/5/2004 00:00:00.000am' is stored as 1081180800. "4/4/2004 11:59:59.000pm'...
1
by: sgh | last post by:
Why doesn't this date time pattern support milliseconds? That makes it hard for me to map my date, time, and dateTime XML schema types to System.DateTime values without losing millisecond...
5
by: ad | last post by:
I have a tabls of SQL 2000, about the data of student. The data is migrate from another databse, There is a field called birthday, it stores the data with the formate like: 1994/11/03 AM 02:09:00...
1
by: Ugur Ekinci | last post by:
Hi , I have two Sql Server 2000 on seperate machines , First one accepts datetime format like ("dd.MM.yyyy hh:mm:ss") And Second one accepts datetime format like ("MM.dd.yyyy hh:mm:ss") 1-...
4
by: Manikandan | last post by:
Hi, I'm inserting a datetime values into sql server 2000 from c# SQL server table details Table name:date_test columnname datatype No int date_t DateTime ...
0
by: maolimix | last post by:
Hi to all, I have a trouble with datetime...now I explain.. I must to store to a C# variable the values from a "Datetime column" of Sql Server 2005. I tried 3 methods ...in the first two I never...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.