Hi,

Clement Ow wrote:
> Clement Ow wrote:
>> 
>>>   puts "I don't want to delete this file"
>>> end
>> 
>> Hi, thanks for that, did'nt know you can do it this way ;)
>> However, I have 2 formats, one yyyymmdd and the other just ddmmyyyy(w/o
>> any dashes). Unfortunately Parsedate cannot be used for ddmmyyyy. Only
>> yyyymmdd can work. Any ideas?
> 
> or is there any way that we can convert something like ddmmyyyy to 
> yyyymmdd so that it'll work when we use Date or parsedate to parse dates 
> in order to not raise an invalid date error?


[sidns@ns ~]$ irb
irb(main):001:0> require 'date'
=> true
irb(main):002:0> Date.strptime('20102008',"%d%m%Y").to_s
=> "2008-10-20"
irb(main):003:0> Date.strptime('20081020',"%Y%m%d").to_s
=> "2008-10-20"


Regards,
Park Heesob
-- 
Posted via http://www.ruby-forum.com/.