Chris Richards
2006-May-09 11:35 UTC
[Rails] How do you Convert a Time or Date to SQL formatted date?
I am executing some arbitrary SQL in which i need to convert a date/time object into an sql formatted string. Is there a simple way to do this in rails? Thanks Chris -- Posted via http://www.ruby-forum.com/.
Jean-François
2006-May-09 12:14 UTC
[Rails] How do you Convert a Time or Date to SQL formatted date?
Hello Chris,> I am executing some arbitrary SQL in which i need to convert a > date/time object into an sql formatted string. Is there a simple > way to do this in rails?Try : my_date.to_s(:db) -- Jean-Fran?ois. -- ? la renverse.
sergio luis
2006-May-09 17:23 UTC
[Rails] Re: How do you Convert a Time or Date to SQL formatted date?
Chris Richards wrote:> I am executing some arbitrary SQL in which i need to convert a date/time > object into an sql formatted string. Is there a simple way to do this > in rails? > > Thanks > Christry to do this date_you_want = "''"+dateTimeVar["year"]+''-''+dateTimeVar["month"]+''-''+dateTimeVar["day"]+"''" and then use it in the sentence. -- Posted via http://www.ruby-forum.com/.