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

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.

Chris R. 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
Chris

try to do this
date_you_want =
“’”+dateTimeVar[“year”]+’-’+dateTimeVar[“month”]+’-’+dateTimeVar[“day”]+"’"

and then use it in the sentence.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs