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. sql function to calculate work hours

sql function to calculate work hours

Scheduled Pinned Locked Moved Database
databasehelp
4 Posts 4 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.
  • A Offline
    A Offline
    Athira G Krishnan
    wrote on last edited by
    #1

    if the shift time is 7pm to 3am..after 12am,it will be considered as next day..and the time after 12am will be calculated as work hour of next day..please help me to write a sql function for this..pls...

    S D 2 Replies Last reply
    0
    • A Athira G Krishnan

      if the shift time is 7pm to 3am..after 12am,it will be considered as next day..and the time after 12am will be calculated as work hour of next day..please help me to write a sql function for this..pls...

      S Offline
      S Offline
      Scubapro
      wrote on last edited by
      #2

      Check this out: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

      1 Reply Last reply
      0
      • A Athira G Krishnan

        if the shift time is 7pm to 3am..after 12am,it will be considered as next day..and the time after 12am will be calculated as work hour of next day..please help me to write a sql function for this..pls...

        D Offline
        D Offline
        David Mujica
        wrote on last edited by
        #3

        Things you may want to consider when designing a system which includes a start time and end time: 1) Store both the date and time. This will make it much easier to determine if a shift crosses a midnight boundary. 2) Use the concept of a "End of Day" time. For example, lots of manufacturing sites use 11pm (23:00) because they consider anyone working after 11pm to be working the next day. 3) Also take into consideration a "Pay Date", typically this is what is considered the day the person works (and gets paid for). For example if your worker starts his shift on Friday at 7pm and works into Saturday morning, he would be paid for working Friday. Not 2 different pay days. (Fri & Sat) Best of luck.

        C 1 Reply Last reply
        0
        • D David Mujica

          Things you may want to consider when designing a system which includes a start time and end time: 1) Store both the date and time. This will make it much easier to determine if a shift crosses a midnight boundary. 2) Use the concept of a "End of Day" time. For example, lots of manufacturing sites use 11pm (23:00) because they consider anyone working after 11pm to be working the next day. 3) Also take into consideration a "Pay Date", typically this is what is considered the day the person works (and gets paid for). For example if your worker starts his shift on Friday at 7pm and works into Saturday morning, he would be paid for working Friday. Not 2 different pay days. (Fri & Sat) Best of luck.

          C Offline
          C Offline
          CitrusTech
          wrote on last edited by
          #4

          Time can be a real nightmare to handle. Other issues which you might want to think about include: Day-light saving time (esp. around midnight boundaries). Time zones -- don't look applicable in your case, but I worked on a car hire problem which supported pickup/drop off across time zones. Of course, I've not actually answered the original question. Some idea of the data structure/data available might be useful.

          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