This is an Access question, not a DBI question but...
In access date literals use the # symbol to quote dates, e.g. #5/10/96#.
Or you can use the DateValue() function to convert from a string.
To get the current date use the Now() function.
So something like this should do the trick:
my $accessth = $Access_dbh->prepare( q{delete from Data
where DATE_TIME < #2001-06-01 12:30:00#)
}) || die "Can't prepare statement: $DBI::errstr";
If you want to make your script more portable you could use the ODBC
functions instead, such as CURRENT_DATE or CURDATE. Remember that date
literals in ODBC have the format {d '1995-01-15'} and functions are
called like using {fn curdate()} so...
my $accessth = $Access_dbh->prepare( q{delete from Data
where DATE_TIME < {d '2001-06-01 12:30:00'})
}) || die "Can't prepare statement: $DBI::errstr";
--
Simon Oliver
[EMAIL PROTECTED] wrote:
> Hi,
>
> How I can delete records from MS Access DB using DBI module.
> I want to delete a records which are "too" old.
>
>
> This would be easy if I could use Oracle DB then would work like this.
>
>
> _____
>
>
> my $accessth = $Access_dbh->prepare( q{delete from Data
> where (DATE_TIME < to_date('2001-06-01 12:30:00', 'YYYY-MM-DD HH24:MI:SS')
> }) || die "Can't prepare statement: $DBI::errstr";
>
> my $rv = $accessth->execute() || die "Can't execute statement:
> $DBI::errstr";
>
>
> _____
>
> But how to do it with Access DB?
--
Simon Oliver
---------------------------------------
Department of Biomolecular Sciences
UMIST, PO Box 88, Sackville St
Manchester, M60 1QD
United Kingdom
Phone: +44 161 200 8912
Fax: +44 161 236 0409
Mobile: +44 776 183 0327
Email: [EMAIL PROTECTED]
---------------------------------------