[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to get date out of datetime field?

Vapor ..

12/9/2007 10:21:00 AM

I have a field in db with datetime format and it contains more than just
simple date. How can I get only date from it?
--
Posted via http://www.ruby-....

3 Answers

Phrogz

12/9/2007 7:03:00 PM

0

On Dec 9, 3:21 am, "Vapor .." <vaqas.ash...@gmail.com> wrote:
> I have a field in db with datetime format and it contains more than just
> simple date. How can I get only date from it?

What does your format look like?
What database are you using?
How are you connecting Ruby to the database? Are you using
ActiveRecord? Something else?

Do you already have instances of a Ruby Time class? DateTime class?

Do you want an instance of a Date class? Do you just want to visually
display the date only information?

More information required...

Vapor ..

12/10/2007 5:20:00 AM

0

Gavin Kistner wrote:
> On Dec 9, 3:21 am, "Vapor .." <vaqas.ash...@gmail.com> wrote:
>> I have a field in db with datetime format and it contains more than just
>> simple date. How can I get only date from it?
>
> What does your format look like?
> What database are you using?
> How are you connecting Ruby to the database? Are you using
> ActiveRecord? Something else?
>
> Do you already have instances of a Ruby Time class? DateTime class?
>
> Do you want an instance of a Date class? Do you just want to visually
> display the date only information?
>
> More information required...

oh well

I am using MySQL and when I look into it, it shows something like
'2007-12-10 18:58:17' like this.

And I am using all the default settings (ActiveRecord and stuff)
--
Posted via http://www.ruby-....

Damjan Rems

12/10/2007 6:25:00 AM

0


You probably look for something like this:

myDate.strftime('%Y%m%d')


by
TheR
--
Posted via http://www.ruby-....