Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:38:38+00:00 2026-06-14T19:38:38+00:00

I have date that I want to increment with 1 millisecond. I am using

  • 0

I have date that I want to increment with 1 millisecond. I am using this sql,

DECLARE @A TABLE
(
    A VARCHAR(2)
)
INSERT INTO @A(A) VALUES ('a1')
INSERT INTO @A(A) VALUES ('b2')
INSERT INTO @A(A) VALUES ('a3')
INSERT INTO @A(A) VALUES ('b4')
INSERT INTO @A(A) VALUES ('a5')
INSERT INTO @A(A) VALUES ('b6')
INSERT INTO @A(A) VALUES ('a7')
INSERT INTO @A(A) VALUES ('b8')

SELECT DATEADD(millisecond, + ROW_NUMBER() OVER (ORDER BY A), '2012-11-22     15:09:24.990'),ROW_NUMBER() OVER (ORDER BY A)
FROM @A

But the result is,

2012-11-22 15:09:24.990 1
2012-11-22 15:09:24.993 2
2012-11-22 15:09:24.993 3
2012-11-22 15:09:24.993 4
2012-11-22 15:09:24.997 5
2012-11-22 15:09:24.997 6
2012-11-22 15:09:24.997 7
2012-11-22 15:09:24.997 8

which is incorrect

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:38:39+00:00Added an answer on June 14, 2026 at 7:38 pm

    The DATETIME datatype in SQL Server has a 3.33ms resolution.

    You will never be able to create 15:09:24.991 and other values – what you’re seeing is expected and documented behavior.

    If you need greater accuracy – use the DATETIME2 datatype instead (which can handle accuracy down to 100ns).

    DECLARE @StartValue DATETIME2(3) = '20121122 15:09:24.990'
    
    SELECT 
        @StartValue,
        DATEADD(Millisecond, 1, @StartValue),
        DATEADD(Millisecond, 2, @StartValue),
        DATEADD(Millisecond, 3, @StartValue)
    

    generates results:

    2012-11-22 15:09:24.990
    2012-11-22 15:09:24.991
    2012-11-22 15:09:24.992
    2012-11-22 15:09:24.993
    

    as you wanted.

    Update: if you must stick with DATETIME – yes, you can add +3 and get these results:

    DECLARE @StartValue DATETIME = '20121122 15:09:24.990'
    
    SELECT 
        @StartValue, 
        DATEADD(Millisecond, 3, @StartValue),
        DATEADD(Millisecond, 6, @StartValue),
        DATEADD(Millisecond, 9, @StartValue)
    

    gives you:

    2012-11-22 15:09:24.990 
    2012-11-22 15:09:24.993 
    2012-11-22 15:09:24.997 
    2012-11-22 15:09:25.000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a table that has event name and event date. if i want
I have an application that passes in java.util.Date. I want to check whether this
Let's say that I want to have a table that logs the date and
I want to create a table that has a birthday date, this column shouldn't
I have a DATE column that I want to round to the next-lower 10
I have a date picker library written for MooTools that I want to port
I have a Date format: 2009-08-10T16:03:03Z that I want to convert to: @MMM dd,
I have have this query that i want to execute. SELECT warehouse.expiry_date, pharmacy.expiry_date, drugs.active_substance,
I have been passed a date string that looks like this: Thu%20Mar%2011%202010%2015%3A09%3A11%20GMT%2B0000%20(BST) I want
I have strings like 84, 03 etc. that I want to convert to Date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.