Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    The sunny side of the Alps
    Posts
    230
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Using time as condition in SQL

    Hi!

    I would like to retrieve records of news that were published between PM 1:00 and PM 3:00.
    How can I form an SQL query that would check the given time interval?

    Thanks,
    Bostjan

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Try:

    SELECT * FROM TableName WHERE [pubdate] BETWEEN #1:00 PM# and #3:00 PM#

    or:

    SELECT * FROM TableName WHERE pubdate BETWEEN '1:00 PM' and '3:00 PM'

    where pubdate is a datetime field.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •