|
-
Jan 20th, 2003, 01:38 PM
#1
Thread Starter
Lively Member
sql statement needed
Been playing with this one and havent had any luck..
How would you write an sql statement to delete any dates previous to today's date.
I've tried the following
ie
sql="delete from MyTable where TheDate<" & date
sql="delete from MyTable where TheDate<" & "#" & date & "#"
sql="delete from MyTable where TheDate<" & "'" & date & "'"
-
Jan 20th, 2003, 01:44 PM
#2
-
Jan 20th, 2003, 01:54 PM
#3
Frenzied Member
If access:
sql="DELETE FROM [MyTable] WHERE [TheDate] < #" & date & "#"
-
Jan 21st, 2003, 02:31 AM
#4
Thread Starter
Lively Member
not yet
I tried that one as well...
This is an Access db.
sql="delete * from [mytable]" deletes all records as expected but I only want to remove dates that have already passed.
sql=delete * from [mytable] where [thedate]<" & date
sql=delete * from [mytable] where [thedate]<" & "#" & date & "#"
sql=delete * from [mytable] where [thedate]<#" & date &"#"
have all been tried unsuccessfully.....
anyone? thx
-
Jan 22nd, 2003, 08:06 AM
#5
Hyperactive Member
hi,
try this
db.execute "delete * from [myTable] where [Datefield]<#" & date & "#"
-
Jan 24th, 2003, 12:46 AM
#6
Fanatic Member
hi try this
con.execute "delete from table where dt < #" & now() & "#"
before it confirm that ur datafiled name is not date
if ur datafiled name is date then u can't delete records..
i hope u confirm it
-
Jan 27th, 2003, 02:49 PM
#7
Thread Starter
Lively Member
still no go
The Date field is called TheDate just for that reason.
I've tried all the suggestion and still can not get dates < todays date to delete from the table.
-
Jan 27th, 2003, 04:15 PM
#8
Frenzied Member
Originally posted by techgnome
SQL Server or Access?
What is a variable name for your date parameter?
Could you post your code here?
-
Jan 27th, 2003, 08:31 PM
#9
are you running the SQL form inside Access???
I just ran this :
DoCmd.RunSQL ("delete * from test where thedate < #" & Date & "#")
(test was my table)
and it worked fine..deleted everything before today
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|