EasyQ
asked on
Need help fast!!
I want to delete items in an SQL-database.
At the moment I use the statement:
rensaStr="DELETE from IntranetUser.aktiviteter WHERE datum < '" &DateValue(DateSerial(year (date()),m onth(date( )),day(dat e())-1))&" "&Time()&"'"
Set rensaoRs = Conn.Execute(rensaStr)
The field "datum" is a date field. What I want to do is to only remove entries which date is passed, not the time. I mean, if the date is set to 4 of july 10 am I want it to be removed as soon as it is the 5:th of july. Not at 10 am the 5:th. Is this possible without extracting, iow just using the delete sentence?
At the moment I use the statement:
rensaStr="DELETE from IntranetUser.aktiviteter WHERE datum < '" &DateValue(DateSerial(year
Set rensaoRs = Conn.Execute(rensaStr)
The field "datum" is a date field. What I want to do is to only remove entries which date is passed, not the time. I mean, if the date is set to 4 of july 10 am I want it to be removed as soon as it is the 5:th of july. Not at 10 am the 5:th. Is this possible without extracting, iow just using the delete sentence?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried this:
Delete from table where convert(varchar(10),datum, 103)<'"&Da teValue(Da teSerial(y ear(date() ),month(da te()),day( date())-1) )&" "&Time()&"'"
It erased all entries before 23 october. So I don't really like what you did... btw what does the convert(varchar(10),datum, 103) really do?
The datum fields data is store like this "10/11/12 11:12 AM"
Delete from table where convert(varchar(10),datum,
It erased all entries before 23 october. So I don't really like what you did... btw what does the convert(varchar(10),datum,
The datum fields data is store like this "10/11/12 11:12 AM"
Convert function converts datetime to varchar datatype,representing only date part.
> if the date is set to 4 of july 10 am I want it to be
> removed as soon as it is the 5:th of july.
If it is so ,why are you adding time portion in your statement ?
>"&Time()&"'"
> if the date is set to 4 of july 10 am I want it to be
> removed as soon as it is the 5:th of july.
If it is so ,why are you adding time portion in your statement ?
>"&Time()&"'"
ASKER
I ad it since the value in the database is stored with the time too. (need to be stored that way) but now that I understand what the convert does, I understand that I shouldn't use the &"time()&"
ASKER