From: Jeremy Bopp Date: 2011-02-03T14:13:11+09:00 Subject: Re: Converting date format (CSV to yaml) On 02/02/2011 11:02 PM, Kamarulnizam Rahim wrote: > But when i tried transferring the ydate into my yaml structure, it still > print out the quotation marks. > > {"type"=>"TargetComponent", > "title"=>"None", > "args"=> > {:start_date=>'2010-08-10', > :end_date=> (ydate), > :state=>"#{status}"}}]} > > My yaml output: > > - type: TargetComponent > title: None > args: > :start_date: "2010-08-10" > :end_date: "2011-01-12" > :state: Active It's because you actually have a String rather than a Date object. Try this in irb: ruby-1.9.2-p136 :001 > require 'yaml' => true ruby-1.9.2-p136 :002 > require 'date' => false ruby-1.9.2-p136 :003 > puts Date.today.to_yaml --- 2011-02-02 => nil ruby-1.9.2-p136 :004 > puts "2011-02-02".to_yaml --- "2011-02-02" => nil The command at :004 is what you're doing, but you want what the command at :003 is doing. Take the advice provided in the post linked below and use Date objects to process your dates instead of Strings: http://www.ruby-forum.com/topic/1005964#979296 -Jeremy