How to pull data based on a time in hours and minutes

Discussion in 'General MSSQL Discussion' started by arkblondy49, Feb 25, 2022.

  1. arkblondy49

    arkblondy49

    Joined:
    Feb 25, 2022
    Messages:
    1
    Likes Received:
    0
    I am trying to pull data for all records before 4:30 pm.
    I tried to use the below query, but I don't think it's pulling the minutes correctly.

    Can someone tell me how to do this properly?

    select a.accession_no,
    a.created_date as "Date Created",
    ISNULL(pe2.last_name,'') as "Last Name",
    ISNULL(pe2.mid_name,'') as "Middle Name",
    ISNULL(pe2.first_name,'') as "First Name",
    ISNULL(pe2.gen_title,'') as "Title",
    ISNULL(pe2.full_name,'') as "Full Name"
    from accession_2 a
    LEFT OUTER JOIN acc_process_step acps on a.id = acps.acc_id
    LEFT OUTER JOIN process_step ps on acps.step_id = ps.id
    LEFT OUTER JOIN personnel_2 pe2 on acps.assigned_to_id = pe2.id

    WHERE datename(hour, created_date) > 16.3
    order by created_date desc
     
    arkblondy49, Feb 25, 2022
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.