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

  • Home
  • SEARCH
  • 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 7849539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:33:26+00:00 2026-06-02T18:33:26+00:00

I have a table timings with 4 different time fields namely : intime, outtime,

  • 0

I have a table timings with 4 different time fields namely : intime, outtime, lunchout, lunchin. I’m trying to find total hours logged i.e ((outtime-intime) – (lunchin-lunchout). Which I can fin out successfully using :

select convert (varchar(10),((outtime_d - intime_a)-(lunchin_c - lunchout_b)),8) as time1 from timings where fname = 'abc'

create table timings
(
fname varchar(max),
fid varchar(30) PRIMARY KEY CLUSTERED,
intime_a datetime,
outtime_d datetime,
lunchout_b datetime,
lunchin_c datetime
)

insert into timings values('Abc','4C00A2C82A0C','4/23/2012 2:07:51 PM','4/23/2012 9:07:51 PM','4/23/2012 4:12:51 PM','4/23/2012 5:07:51 PM')
time1 = 06:05:00

I have another table called attendance with the following fields : fname, presenttime, date.

create attendance timings
(
fname varchar(max),
presenttime datetime,
date datetime
)

I need to insert into attendance:

fname: fname from timings

presenttime: time1 – the result of above listed query

date: current system date. (only date, not time, need to remove timestamp from getdate() function)

I first attempted to use the datediff function, and late concatenate the values, but I was getting incorrect results.

SELECT ROUND(cast((datediff(hh, outtime_d ,intime_a) / 60.0) as FLOAT),2) AS DiffHour from timings where fname = 'abc'
SELECT ROUND(cast((datediff(mi, outtime_d ,intime_a) / 60.0) as FLOAT),2) AS DiffMinute from timings where fname = 'abc'
SELECT ROUND(cast((datediff(ss, outtime_d ,intime_a) / 60.0) as FLOAT),2) AS DiffSec from timings where fname = 'abc'

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-02T18:33:28+00:00Added an answer on June 2, 2026 at 6:33 pm

    I ended up changing both the field’s datatypes to varchar

    and used this:

    insert into attendance(fname,presenttime,date)
    SELECT 
    fname, 
    CAST(CONVERT (VARCHAR(10),((outtime_d - intime_a)-(lunchin_c - lunchout_b)),8) AS varchar(10)),
    CONVERT (VARCHAR(10),getdate(),3)
    FROM timings WHERE fname = 'abc'
    

    The results are satisfactory for now.

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

Sidebar

Related Questions

I have table with a unique auto-incremental primary key. Over time, entries may be
I have a table A which maintains count of total users in Table B.
Have table and several div elements. Table is time grid and divs are events
I have table in my database which has fields of ID,NAME,CONTEXT. I am showing
I have table with permissions that has few bit fields. I want to group
i have table structure with 3 colums (column1, column2, column3) and i want to
I have table with 3 columns A B C. I want to select *
i have table unser it i have one td with elemets inside the menu
I have table in data base name train delay, with columns train number(int), DelayTime(int),
I have table A in Oracle that has a primary key (id). I need

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.