473,714 Members | 2,552 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 5486

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
3802
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
2000
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
5495
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
6437
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
6306
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
2665
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
2880
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
5591
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
2821
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
8801
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
8707
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
9314
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
9174
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6634
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
5947
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4464
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3158
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 we have to send another system
3
2110
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.