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. Grouping by time period

Grouping by time period

Scheduled Pinned Locked Moved Database
databasecomquestion
2 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.
  • J Offline
    J Offline
    Jeff Martin
    wrote on last edited by
    #1

    I'm trying to create a query that counts records based on time periods. I'm querying two tables, one containing SubmittedDate, the other CompletedDate. I'm using DateDiff to calculate the time difference between the two. What I want to do is end up w/ a count for mulitple periods of time like.... < 2 Hours 3 2 - 4 Hours 6 4-8 Hours 10 1 Day 12 1 - 3 Days 8 5 Days 4 > 5 Days 2 Any ideas? Jeff Martin My Blog

    C 1 Reply Last reply
    0
    • J Jeff Martin

      I'm trying to create a query that counts records based on time periods. I'm querying two tables, one containing SubmittedDate, the other CompletedDate. I'm using DateDiff to calculate the time difference between the two. What I want to do is end up w/ a count for mulitple periods of time like.... < 2 Hours 3 2 - 4 Hours 6 4-8 Hours 10 1 Day 12 1 - 3 Days 8 5 Days 4 > 5 Days 2 Any ideas? Jeff Martin My Blog

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      You could write a UDF (User defined function) that returns the time period and then use that in your query.


      Cada uno es artifice de su ventura WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums

      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