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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:08:35+00:00 2026-06-17T16:08:35+00:00

Summary: How to extract records that belong to the UTC time interval, when the

  • 0

Summary: How to extract records that belong to the UTC time interval, when the UTC time in the key column is encoded?

The UTC encoding: I do have a third-party table where records contain UTC time encoded as strings like '2456065.80700942:0000002F'. To get the UTC of the DATETIME type, the following formula can be used:

CAST((CAST(LEFT(encodedUTC, 16) AS FLOAT) - 2415020.5) AS DATETIME)

They say, the part before the colon is the Julian date encoded to float (and the float to the string). I did not check, it seems to work.

The query: Now I have @fromUTC and @toUTC of the DATETIME type. I can select:

SELECT CAST((CAST(LEFT(d.UTC, 16) AS FLOAT) - 2415020.5) AS DATETIME) AS UTC,
       ...
FROM dbo.Data AS d
WHERE CAST((CAST(LEFT(d.UTC, 16) AS FLOAT) - 2415020.5) AS DATETIME) > @fromUTC 
      AND CAST((CAST(LEFT(d.UTC, 16) AS FLOAT) - 2415020.5) AS DATETIME) < @toUTC

(I am not using BETWEEN as I do not want to get the records with equal times.) It works, but the problem is that the conversion formula is repeated 3 times (and I do not like the repeating of the same code if it is not neccessary).

My question is: How can I write the SELECT better?

Thanks for your time and information,

Petr

  • 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-17T16:08:36+00:00Added an answer on June 17, 2026 at 4:08 pm

    I’d consider either adding a view that includes this calculation, or a computed column on the table itself (if you can change the table definition).

    Either of these approaches would lead to a cleaner final select. There’s likely some performance considerations based on how often you select versus insert, so will probably shade you one way or the other.

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

Sidebar

Related Questions

I have to extract summary from newspaper article . The summary is extracted based
Summary: I have passed the name of the id select tag into an Array.
Summary: I'm trying to write a text string to a column of type varchar(max)
I have a bunch of XML files, along with the DTD, that each have
I'm building a summary table as part of a stored procedure and I have
In the past we have been using a summary of historical performance by Vendor
I am using BeautifulSoup to extract tabledata tags from a table. The TD's have
I have a form view model class that populates Select Lists for use by
I have several large Javascript files that I need to document/digg into. Unfortunately I
I want to extract the fstatistic value from summary(lm()). So far the only way

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.