on 8/30/2005 2:13 PM kevin evans said the following:
> I''m having a problem with a DATETIME field in mysql and Rails.
> Basically, it seems to revolve around a difference between the format
> activerecord is creating a date and subsequently updating the field.
>
> The application reads a XML file, which includes a
''capturedate'' in
> the format ''28/8/05 18:32:11''
>
> within my controller I do a..
>
> @pic.capturedate = DateTime.strptime(@capturedate,"%d/%m/%Y
%H:%M:%S")
>
> and the data is saved. At this point an examination of the db show a
> datetime of 05-08-28 18:32:11
>
> however, if I subsequently edit some data from this record (data does
> not mention ''capturedate'') - via a rails form and then
perform an update
>
> @picture = Picture.find(params[:id])
> @picture.update_attributes(params[:picture])
>
> the capturedate field gets changed to ''2005-08-08
18:32:11'' note
> extra ''20'' on year.
This is a formatting problem. Change the format string in capturedate
"%y" instead of %Y, then all of your dates will be 2005. This is the
right thing to do, unless you really do have data from 5 CE, in which
case you will need to track down the bug in update attributes.
Ray