How do I pull records based on a certain time frame?

  • I am trying to pull records after 4:30 pm.

    I am able to use this, but I don't think it works properly for minutes.

    Does anyone know how do to this in MSSQL?

    select a.accession_no,

    a.created_date as "Date Created"

    from accession_2 a

    WHERE datename(hour, created_date) > 16.3

    order by created_date desc

  • I don't think any date functions return a decimal.

    Either of these might work.

    SELECT TOP 100 [name], create_date,
    DATEPART(hour, create_date),
    DATEPART(minute, create_date)
    FROM SYS.OBJECTS
    WHERE CONVERT(TIME(0), create_date) > '16:30:00';



    SELECT TOP 100 [name], create_date,
    DATEPART(hour, create_date),
    DATEPART(minute, create_date)
    FROM SYS.OBJECTS
    WHERE (DATEPART(hour, create_date) = 16 AND DATEPART(minute, create_date) >= 30 AND DATEPART(second,create_date) >0)
    OR ( DATEPART(hour, create_date) > 16);

    • This reply was modified 2 years, 7 months ago by  Ed B.
  • Thank you!  This worked great!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply