From: "Peña, Botp" Date: 2007-09-03T10:43:03+09:00 Subject: Re: calendar events From: Michael Linfield [mailto:globyy3000@hotmail.com] # res = [] # array = ["2/14/2005",83,35,23] # res << array.grep(/2/\14/\2005/) # so now res has "2/14/2005" in it...how would i turn that into a -- # specdate = Date.new(2, 24, 2005) # so i need 2/14/2005 turned into a date object, preferably not # having to use the format of Date.new(year,day,month) # ...id prefer to have it in # the format of month,day,year if possible :) hmmm, you already have that copy in array. why not put a date object right into res. one you have the date obj, you can format it anyway you like eg, irb(main):019:0> res=[] => [] irb(main):020:0> array = ["2/14/2005",83,35,23] => ["2/14/2005", 83, 35, 23] irb(main):025:0> res << Date.strptime(array.first, "%m/%d/%Y") => [#] now res contains a date object it's now a date object, so you format it w your hearts content.. irb(main):031:0> res[0].strftime("%m-%d-%y") => "02-14-05" irb(main):032:0> res[0].strftime("%m/%d/%y") => "02/14/05" irb(main):039:0> res[0].strftime("%m/%d/%Y") => "02/14/2005" irb(main):040:0> res[0].strftime("%m:%d:%Y") => "02:14:2005" irb(main):041:0> res[0].strftime("%m %d %Y") => "02 14 2005" irb(main):042:0> res[0].strftime("<%m> <%d> <%Y>") => "<02> <14> <2005>" irb(main):043:0> res[0].strftime("Month: %m\nDay: %d\nYear: %Y\n") => "Month: 02\nDay: 14\nYear: 2005\n" irb(main):044:0> puts res[0].strftime("Month: %m\nDay: %d\nYear: %Y\n") Month: 02 Day: 14 Year: 2005 => nil kind regards -botp