Databases usually have a Date and Time set of functions and you can
use them to combine this two parts in one DateTime.

As suggested you can always use DateTime.strptime or Time.parse and
Time.to_datetime or any other way of string to DateTime
transformation.
You should ask your self do you need to make this transformation every
time you collect data from the table in question or you can make your
life a little easier with merging the two fields (Date and Time) in
one (DateTime).

There are a bunch of possibilities and the optimum one depends on your
overall usage of that data and plans for future usage.

On Dec 26, 9:08 pm, "Ruby on Rails: Talk" <dazzaroo...@gmail.com>
wrote:
> Probably not the most elegant of solutions (and please let me know if
> there are any better) but this is the best I have come up with!
>
> dt = DateTime.parse("#{tapp.appdate}T#{tapp.apptime.strftime("%H:%M:
> 00")}")
>
> On Dec 26, 8:00 pm, "Ruby on Rails: Talk" <dazzaroo...@gmail.com>
> wrote:
>
> > Hi
>
> > I have a database with a seperate Date and Time fields.
>
> > I'm trying to work out how to search, return and combine the two,
> > turning them into one DateTime value so that I can then compare it to
> > the current date and time and see if it's in the future or past.
> > However, I'm having no luck unfortunately.
>
> > Can anyone point me in the right direction?
>
> > I've searched for hours for this and having no real luck.
>
> > Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to