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 6055487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:16:12+00:00 2026-05-23T08:16:12+00:00

I really can’t figure out why the instruction SELECT CONVERT(NVARCHAR(30), GETDATE(), 114) outputs, for

  • 0

I really can’t figure out why the instruction SELECT CONVERT(NVARCHAR(30), GETDATE(), 114) outputs, for instance,

13:04:31:997

instead of

13:04:31.997

Why is the milliseconds separator a : insted of a .? In case you need to know, I need to be able to check if a certain time is between two time values stored as XML in a table. The problem is that the separator in this table is, as it is normal for me, a ., so that using comparisons between the two formats returns wrong results because one uses . and the other uses :. Is there any way I can get the time with the . separator without using string functions like REPLACE or without changing the format stored in the table?

  • 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-05-23T08:16:12+00:00Added an answer on May 23, 2026 at 8:16 am

    I think you should try to keep the format as datetime when you do the comparison. In SQL Server 2008 there is a new data type time that would have been helpful but in SQL Server 2005 we have to use datetime instead.

    I guess that you are using convert(..., 114) to only get the time part from a datetime variable. You can use this code to remove the date part and still have a datetime variable.

    declare @dt datetime
    set @dt = '2001-01-01T10:01:02.000'
    select dateadd(d, datediff(d, @dt, 0), @dt)
    

    Result:

    1900-01-01 10:01:02.000
    

    When you extract data from XML using .value you specify the datatype to be used. If you only have the time part in the XML and you specify datetime you will get the time of the date ‘1900-01-01’. So you can do the comparison using datetime like this.

    declare @T table (ID int, XMLCol xml)
    
    insert into @T
    select 1, '<t1>10:01:01.123</t1><t2>10:01:02.123</t2>' union all
    select 2, '<t1>11:01:01.123</t1><t2>11:01:02.123</t2>'
    
    declare @dt datetime
    set @dt = '2001-01-01T10:01:02.000'
    
    select T.ID
    from @T as T
    where dateadd(d, datediff(d, @dt, 0), @dt) between 
            T.XMLCol.value('t1[1]', 'datetime') and 
            T.XMLCol.value('t2[1]', 'datetime')  
    

    Result:

    ID
    1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really can't figure it out. I'm new to Mercurial and TortoiseHg. Read alot
Looks like I've missed something obvious but really can't figure out why I can't
I'm doing some MonoTouch development, and I really can't figure out an problem I've
I am trying to something I really can't figure out. I have an iFrame
I have to be dead tired because I really can't figure out such simple
I really can't figure out why my code isn't working because Twilio's debugger isnt
I really can't figure out what's going on in this case. On the multiline
I really can't figure this one out... I'm trying to achieve the following result
my question is really basic but I really can't figure out how to do
I'm getting nuts with this thing. I really can't figure out what's the issue

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.