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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:48:15+00:00 2026-06-10T06:48:15+00:00

In My SQL Query I Return Column with Difference Between GetDate() and Column Named

  • 0

In My SQL Query I Return Column with Difference Between GetDate() and Column Named “OriginalFaultOccuredOn” (DataType is DateTime).I have done some Converion so That it will show me diiference in Format Like 5.56 (5 Hours and 56 Minutes)

Result is Like

<Column Name>

3.45
5.55
1.23
10.65

I want to Modify it in Further Way that it Shud Print Result like

More Than 6 Hours  More THan 12 Hours More than 24 Hours
3                  5                  6 

My SQL Query Look like:-

    Select Floor(Convert(Numeric(18,2),Convert(Numeric(18,2),DateDiff(MI, OriginalFaultOccurredOn, GetDate()))/60)) + 
Convert(Numeric(18,2),((Convert(Numeric(18,2),Convert(Numeric(18,2),DateDiff(MI, OriginalFaultOccurredOn, GetDate()))/60) -
Floor(Convert(Numeric(18,2),Convert(Numeric(18,2),DateDiff(MI, OriginalFaultOccurredOn, GetDate()))/60)))*0.6))[Time] 
From Ticket Where Closed=0

DataBase is MS-SQL Server

  • 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-10T06:48:17+00:00Added an answer on June 10, 2026 at 6:48 am

    You might count occurrences that fall in specified range by adding one each time a match is found:

    select sum(case when [time] > 6 and [time] <= 12 then 1 end) [More than 6 hours],
           sum(case when [time] > 12 and [time] <= 24 then 1 end) [More than 12 hours],
           sum(case when [time] > 24 then 1 end) [More than 24 hours]
    from
    (
     { your-query-here }
    ) a
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have sql query select * from Roles Join Users On Roles.Role=Users.RoleId it return
I'm using MS SQL 2005 and I have created a CTE query to return
Given SQL as an input, I have to query a PostgreSQL database and return
I have following SQL query that selects some results from my table: select avg(c3),
Here is the simple sql query that will return all tables that have the
Is there a way to get the columns that a SQL query would return
I'm using Sql-Server, and I have the below query which returns all columns that
I'm trying to get the IsAdmin Value with SQL query(This query return 1 line
How do I return the everything in a string from a sql query before
I am working on a query for SQL Server 2005 that needs to return

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.