473,836 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
+ 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 5493

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.ht m
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
3812
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 counter functionality and read/insert some data in a MS Access database on that Windows 2003 server. The weird part is, as long as the web page is very short in size, I can hit the refresh button and Internet Explorer will reload the page and display...
2
2003
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 overcome the slowness, they have installed a new server with SQL Server 2000 Enterprise Edition with 'Log Shipping' enabled (to provide a subsidiary database on which reports can be run) but although the speed issue is resolved, there are hitherto...
8
5499
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 (fldDateEntered <= CONVERT(DATETIME, '2003-11-23 23:59:59', 102)))
1
6438
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' is 1081180799. I need to generate reports that display datetime columns in "mm/dd/yyyy hh:mn:ss" format with am or pm at the end. Bellow is my query statment. select iorg_name as org, ref_num as , c_first_name as , c_last_name as , sym as...
1
6318
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 precision. The DateTime.ToString("u") format specifier chops off the milliseconds of my values :( Anybody got a work-around for this?
5
2668
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 When I bind the field to datagrid, how can I suppress the time part , or how can I trim the time part form database?
1
2883
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- Date formats are different because of SQL Collation? 2- Do regional Settings affect Sql date format? 3- (Important) When inserting a datetime into first server there is no problem (15.12.2000 12:12:12) , but when I insert into second server (if...
4
5600
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 C# coding
0
2836
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 was able to get the Millisecond from datacolumn. I explain the methods... 1) I created a Datatable that contain the column... then I fill a datarow with the current value. The system automatically converts the Sqldatetime in System.Datetime but...
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9671
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10852
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10255
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9382
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7793
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4021
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.