in reply to Re: Dates and SQL
in thread Dates and SQL

I've tried this, unfortunately I get a "Syntax error in UPDATE statement."
Any other ideas?
This is what it looks like now:
my $cur_time = time2str("%c", time()); $sth = $dbh->prepare("UPDATE Schedules SET Date = '$cur_time' WHERE ID + = $id") or die "Couldn't prepare statement: $DBI::errstr; stopped";

Replies are listed 'Best First'.
Re: Re: Re: Dates and SQL
by Jonathan (Curate) on Sep 27, 2001 at 11:14 UTC
    I looks like that your Database doesn't recognise the string as a date. Check what it does accept and format your date accordingly. If you don't have any documentation select back a date and look at how it is formatted. It will most probably accept that as an input
    For easy date formatting I often use the POSIX module's strftime routine to format the date. e.g.
    use POSIX qw(strftime); my $cur_time = strftime "%m %d %Y", localtime;