access delete row by date

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have an access file with a datetime column. Apparently access doesn't have
just a date option when creating a column. I would like to create a query in
a dataset to erase all entries for a particular date. However when I say;

DELETE FROM Table WHERE (Date_Downloaded = ?)

nothing is deleted because it's not exact to the second. '12/20/2008
10:30:22 AM' How can I rework my statement where all entries for a given date
will be deleted.
 
Dave said:
I have an access file with a datetime column. Apparently access doesn't
have
just a date option when creating a column. I would like to create a query
in
a dataset to erase all entries for a particular date. However when I say;

DELETE FROM Table WHERE (Date_Downloaded = ?)

nothing is deleted because it's not exact to the second. '12/20/2008
10:30:22 AM' How can I rework my statement where all entries for a given
date
will be deleted.

This is one way to do it:

string sql = "Delete from Table Where Date_Downloaded>=? AND
Date_Downloaded<?";
DateTime theDate = new DateTime(2008, 20, 12);
OleDbCommand cmd = new OleDbCommand(sql, connection);
cmd.Parameters.AddWithValue("from", theDate);
cmd.Parameters.AddWithValue("to", theDate.AddDays(1));
cmd.ExecuteNonQuery();
 
I think there is a DATE function, try this

where Date(Date_Downloaded) = ?


If not then take a look at Access's date functions, there is one there
somewhere.
 
Back
Top