Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
i want convert rows to Colums with specific data in JavaScript array

I have a Array in multiple Time-In or Time-Out , Break In or Break out. i want to calculate total duration from Time-In to Time-Out

Here is data.

const data = 
  [ { timeSheetDetailActivityId : 0
    , timeSheetDailyActivityId  : 0
    , entryDateTime             : '02:28'
    , activityTypeId            : 'Time In'
    , comments                  : 'dgdfgdfg'
    , isLeave                   : ''
    } 
  , { timeSheetDetailActivityId : 0
    , timeSheetDailyActivityId  : 0
    , entryDateTime             : '03:28'
    , activityTypeId            : 'Time Out'
    , comments                  : '2323'
    , isLeave                   : ''
    } 
  , { timeSheetDetailActivityId : 0
    , timeSheetDailyActivityId  : 0
    , entryDateTime             : '04:28'
    , activityTypeId            : 'Break In'
    , comments                  : '2323'
    , isLeave                   : ''
    } 
  , { timeSheetDetailActivityId : 0
    , timeSheetDailyActivityId  : 0
    , entryDateTime             : '05:28'
    , activityTypeId            : 'Break Out'
    , comments                  : '2323'
    , isLeave                   : ''
    } 
  , { timeSheetDetailActivityId : 0
    , timeSheetDailyActivityId  : 0
    , entryDateTime             : '06:28'
    , activityTypeId            : 'Time In'
    , comments                  : '2323'
    , isLeave                   : ''
    } 
  , { timeSheetDetailActivityId : 0
    , timeSheetDailyActivityId  : 0
    , entryDateTime             : '07:28'
    , activityTypeId            : 'Time Out'
    , comments                  : '232323'
    , isLeave                   : ''
    } 
  ] 

here is Input form you can check input fields for better understanding

so first Time-in was 2:28 or Time-out 3:28 and hour will be 1. after break-in or break out again Time-in is 6:28 or Time-out 7:28 and hour will be 1. now hours is 2. Please any body suggest how I can get total duration 2 in using JavaScript , Typescript.

my suggestion is if i convert above data to get row to Colum with Time-In or Timeout data or calculate duration in next Colum e.g

[ { timeSheetDailyActivityId : 1
  , Time In                  : '02:28'
  , Time Out                 : '03:28'
  , Duraion                  : 1
  , Break In                 : '02:28'
  , Break Out                : '03:28'
  } 
, { timeSheetDailyActivityId : 2
  , Time In                  : '06:28'
  , Time Out                 : '08:28'
  , Duraion                  : 1
  , Break In                 : '02:28'
  , Break Out                : '03:28'
  } 
]

to like this

then i can achieve my goal.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!