1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

SQL Query help required with date/time field

Discussion in 'Business Applications' started by Reuel Miller, Feb 19, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. Reuel Miller

    Reuel Miller Thread Starter

    Joined:
    Feb 17, 1999
    Messages:
    1,821
    Greetings

    It's been a long time since I last posted here, but hopefully all you wonderful people will be able to help...

    Here is my problem:

    A customer of mine has a SQL database where one of the fields is a date/time field that looks like this:

    13/02/2003 14:32:58
    14/02/2003 08:59:10
    15/02/2003 17:09:37

    Now, I need to delete all the records for a particular day (One of their HD's failed, and they had to restore the data and lost a day, but the entries are still in the database, and can not be re-entered until the old entries are deleted).

    How do I structure a query to delete all the records for a particular day? Preferably, I would like a SELECT statement first, just to check that the records found correspond to the delete criteria, and then the DELETE statement.

    Thanks

    Reuel Miller

    The Ex-NT moderator on this board

    Every morning is the dawn of a new error
     
  2. Reuel Miller

    Reuel Miller Thread Starter

    Joined:
    Feb 17, 1999
    Messages:
    1,821
    Greetings

    Not to worry chaps, I figured out the answer all by my lonesome :)

    the statements I used were:

    select * from {database name} where {date field} > '14 February 2003' and {date field} < '15 February 2003'

    delete from {database name} where {date field} > '14 February 2003' and {date field} < '15 February 2003'


    cheers

    Reuel Miller
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/119660