If the value you are getting from the database is a string, try this:

irb(main):004:0> require 'date'
=> true
irb(main):005:0> dt = DateTime.parse('2007-12-30')             =>
#<DateTime: 4908929/2,0,2299161>
irb(main):006:0> dt.year
=> 2007
irb(main):007:0> dt.day
=> 30
irb(main):008:0> dt.month                                                =>
12
irb(main):010:0> str = dt.strftime('%m/%d/%Y')                  =>
"12/30/2007"

If the value you are getting isn't a string then you'll either have to
convert it to a Date or a string and go from there.

-andy


On Thu, Oct 9, 2008 at 1:03 PM, Jason Trebilcock <[EMAIL PROTECTED]
> wrote:

> Doing it through SQL:
>
> select date_format(now(), '%m/%d/%Y')
> Replace now() with your variable and give it a whirl.
>
>
> On Thu, Oct 9, 2008 at 11:08 AM, Moochie <[EMAIL PROTECTED]>wrote:
>
>>
>>
>> How can I convert the following dateformate?
>>
>> puts "2007-12-30".strftime("%m/%d/%Y")
>> puts "2007-12-30".to_a.strftime("%m/%d/%Y")
>>
>> The I've pulled the date from the database, but I want to format as
>> 12/30/2007.
>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to