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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:29:09+00:00 2026-06-16T23:29:09+00:00

I currently have a column TotalHours that contain a computed column specification with the

  • 0

I currently have a column TotalHours that contain a computed column specification with the following

(isnull(datediff(minute,[RegIn],[RegOut]),(0))/(60.0))

This gives me the total hours between 2 columns regin, and regout.

Now. I am trying to subtract 30 minutes from the total hours when the computed hours is above 6.5 hours.

I tried doing it with case statement. but got lost.

Appreciate any help or pointers

Thanks.

  • 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-16T23:29:10+00:00Added an answer on June 16, 2026 at 11:29 pm

    Since you’ve got a complicated expression for the value, you’ll have to use that expression multiple times. One way to think it through is replace the complicated expression with a placeholder, like TotalHours, then put the expression back once you figure out the logic.

    TotalHours - 
        Case When TotalHours > 6.5 Then 0.5 Else 0 End
    

    This says the total hours should be reduced by a value of 0.5 (30 minutes) when the total hours is larger than 6.5 hours. Writing it the way above reduces the repitions of TotalHours. Now plug the original complex expression back in:

    (isnull(datediff(minute,[RegIn],[RegOut]),(0))/(60.0)) -
        Case When (isnull(datediff(minute,[RegIn],[RegOut]),(0))/(60.0)) > 6.5
            Then 0.5 Else 0 End
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a model Attend that will have a status column, and this
I currently have data that is in the following format (note, this is 1
Currently I have an address column that is an embedded document in my users
I currently have a varchar(255) column that stores the path to a small image
I currently have a table with an id column that is being autoincremented and
I currently have this code which stores XML into an XML-type column called data,
I currently have a Postgres 8.4 database that contains a varchar(10000) column. I'd like
Currently I have a User table that has a toys_owned column that is an
I currently have a drop-down menu box that takes an element from a column
I currently have a table that looks something like this: +------+-------+------------+------------+ | id |

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.