From: 7stud -- Date: 2007-09-23T22:19:05+09:00 Subject: Re: Questions about Date.strptime 7stud -- wrote: > > Try this: > Whoops. I forgot to post a solution for that leading "0" in the month: require "date" str = '2007.09' pieces = str.split(".") begin year = Integer(pieces[0]) month = pieces[1] if month[0, 1] == '0' month = Integer(month[1,1]) else month = Integer(month) end rescue ArgumentError puts "invalid date string: couldn't convert to ints" end begin d = Date.new(year, month, 1) puts d.year puts d.month rescue ArgumentError puts "invalid date args, e.g. day = 32" end -- Posted via http://www.ruby-forum.com/.