Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how i can take the sum of times

how i can take the sum of times

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    syed saba
    wrote on last edited by
    #1

    Hi, I am using sql server 7.0 in that i am having a table of 3 feild i.e. empName, Logindate, HoursWorked select * from tablename Result: empName LoginDate HoursWorked ------- ------------ ------------ Amit 06/03/04 13:44:45 Amit 06/04/04 14:44:45 now i want the sum of the field "HoursWorked" Can any body help? Actually im taking 'LoginTime' and 'LogoutTime' Datatype 'DateTime' from "login" table and subtraction of this two field is strored in field 'TimeDiffrence' datatype varchar Query i m using is "convert(varchar(8),(logoutTime-loginTime),14)Timediffrence" now i want the sum of the field "Timediffrence"

    W 1 Reply Last reply
    0
    • S syed saba

      Hi, I am using sql server 7.0 in that i am having a table of 3 feild i.e. empName, Logindate, HoursWorked select * from tablename Result: empName LoginDate HoursWorked ------- ------------ ------------ Amit 06/03/04 13:44:45 Amit 06/04/04 14:44:45 now i want the sum of the field "HoursWorked" Can any body help? Actually im taking 'LoginTime' and 'LogoutTime' Datatype 'DateTime' from "login" table and subtraction of this two field is strored in field 'TimeDiffrence' datatype varchar Query i m using is "convert(varchar(8),(logoutTime-loginTime),14)Timediffrence" now i want the sum of the field "Timediffrence"

      W Offline
      W Offline
      WoutL
      wrote on last edited by
      #2

      try:

      Select empName, Sum(Cast(HoursWorked as int))
      From tablename
      Group by empName

      Or

      Select empName, HoursWorked = Sum(DateDiff(ss, LoginTime, LogoutTime)) / 3600
      From login
      Group by empName

      Wout Louwers

      S 1 Reply Last reply
      0
      • W WoutL

        try:

        Select empName, Sum(Cast(HoursWorked as int))
        From tablename
        Group by empName

        Or

        Select empName, HoursWorked = Sum(DateDiff(ss, LoginTime, LogoutTime)) / 3600
        From login
        Group by empName

        Wout Louwers

        S Offline
        S Offline
        syed saba
        wrote on last edited by
        #3

        Thanks let me check it out

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups