From: Vance A Heron Date: 2006-12-06T07:16:53+09:00 Subject: Re: dates, scheduling tasks, mysql Comfort Eagle wrote: > Paul Lutus wrote: > >> Comfort Eagle wrote: >> >> >>> What is the best Date format for working with dates in ruby & mysql? >>> >> As to MySQL, you really need to stick to a strict date format of >> yyyy-mm-dd. >> This is MySQL's date format when shown in plain text. >> >> >>> I have a recurring task that once complete I want to update the db to >>> reflect the next time to do it. >>> >>> "2006-11-30" as a string ends up being just "2006". >>> >> This didn't happen by magic, you created it with some code. If you show >> us >> the code, we will show you the magic. >> > > > class Date > def Date.now > return Date.jd(DateTime.now.jd) > end > end > > url ='http://xxx.com' > begin > date = Date.now.to_s > p date > dbh = Mysql.real_connect("localhost", "xxx", "xxxx", "xxxxx") > chg = dbh.query("UPDATE sites set updated='#{date}' where > url='#{url}'") > > Not sure why exending Date doesn't work (at least in irb), but I believe you want to be defining the method 'now' (not Date.now??) As an alternate way to do this you could try $ irb irb(main):001:0> date = Time.now.strftime('%Y-%m-%d') => "2006-12-05" irb(main):002:0> hth, Vance