# Fastercsv date problem

**URL:** <https://www.ruby-forum.com/t/fastercsv-date-problem/126773>\
**Category:** Rails\
**Created:** [January 22, 2008, 2:59am UTC](https://www.ruby-forum.com/t/fastercsv-date-problem/126773 "2008-01-22T02:59:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jojobert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee7513/32.png) [@jojobert](https://www.ruby-forum.com/u/jojobert)\
**Post date:** [January 22, 2008, 2:59am UTC](https://www.ruby-forum.com/t/fastercsv-date-problem/126773/1 "2008-01-22T02:59:58Z")

</div>

this is my controller:

class ExportController \< ApplicationController

# example action to return the contents

# of a table in CSV format

def curriculumplans  
programmes = Programme.find(:all)  
degrees = Degree.find(:all)  
stream\_csv do |csv|  
programmes.each do |p|  
csv \<\< [p.programme\_name]  
csv \<\< [“Programme Code:”, p.programme\_code]  
csv \<\< [“Curriculum Plan Dated:” ,  
p.created\_at.strftime("%d-%m-%y")]  
csv \<\< []  
csv \<\< [“Compulsory Courses:”, p.ct\_compulsory]  
csv \<\< [“Elective Courses:”, p.ct\_elective]  
csv \<\< [“Major Elective Courses:”, p.ct\_majorelective]  
csv \<\< [“Minor Elective Courses:”, p.ct\_minorelective]  
csv \<\< [“Major Minor Courses:”, p.ct\_majorminor]  
csv \<\< []  
csv \<\< [“Course Code”,“Course Name”,“Credit Units”,"'Jul 08","'Jan  
09","'Jul 09","'Jan 10",“Last Semester of Presentation”,“Excluded  
Combination”,“Grouping”,“Remarks”,“Day”,“Week”,“Term”,“Course Type”]

```
  degrees.each do |d|
    csv << [d.course.course_code, d.course.course_name,

```

d.course.creditunit.cu, d.course.jul08, d.course.jan09, d.course.jul09,  
d.course.jan10, d.course.lmonth.month + d.course.lyear.year,  
d.course.excluded\_combination, d.course.grouping, d.course.remark,  
d.course.day.day, d.course.week.week, d.course.term.term,  
d.coursetype.coursetype]  
end  
end  
end  
end

private  
def stream\_csv  
filename = params[:action] + “.csv”

```
   #this is required if you want this to work with IE
   if request.env['HTTP_USER_AGENT'] =~ /msie/i
     headers['Pragma'] = 'public'
     headers["Content-type"] = "text/plain"
     headers['Cache-Control'] = 'no-cache, must-revalidate,

```

post-check=0, pre-check=0’  
headers[‘Content-Disposition’] = “attachment;  
filename=”#{filename}""  
headers[‘Expires’] = “0”  
else  
headers[“Content-Type”] ||= ‘text/csv; charset=iso-8859-1;  
header=present’  
headers[“Content-Disposition”] = “attachment;  
filename=”#{filename}""  
end

```
  render :text => Proc.new { |response, output|
    csv = FasterCSV.new(output, :row_sep => "\r\n")
    yield csv
  }
end

```

end

1. somehow the “Jul 08”, “Jan 09”, “Jul 09”, “Jan 10” column names does  
not appear as i’ve typed in the excel file

it appears as 8-Jul, 9-Jan, 9-Jul, 10-Jan instead.

1. also for the “Last Semester of Presentation” \>\> u.lmonth.month +  
u.lyear.year

it comes out as eg. Feb-09 or Jan-14 (it’s supposed to come out like  
“Jan 2004”)

in the database, lyear.year is stored in full (2004, 2014)

how do i change the controller such that the excel csv will stop messing  
with my dates?

(i’m using the plugin fastercsv)  
thank you in advance!
