Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:59:58+00:00 2026-06-16T00:59:58+00:00

If I have a :due column that is a datetime type, how would I

  • 0

If I have a :due column that is a datetime type, how would I make calling .strftime on it work?

For instance, I have

<% @todos.each do |todo|%>
   <%= todo.due.strftime("%h %d") %>
<% end %>

in my show view and I get undefined method `strftime’ for nil:NilClass

I have this in my show method in the controller:

@todos = ProjectTodo.for_project(params[:id])

Note: I’m not trying to display when it was updated or created, just want to display a formatted date.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:59:59+00:00Added an answer on June 16, 2026 at 12:59 am

    try this..

     <% @todos.each do |todo|%>
     <%= todo.due ? todo.due.strftime("%h %d") : nil %>
     <% end %>
    
    
          If the date is there then it will convert to the given format else it will display nil.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C++ program that crashed due to a bug. It would not
I have a dataGridView that has a column called Date Due which is of
I have a table with a column that needs the data type upgrading. However
I have a varchar column that I have datetime values and now string values.
I have a large textfile, which has linebreaks at column 80 due to console
I have a table called, tblClient with an encrypted column called SSN . Due
My web application consists of library type system where books have due dates. I
I have some idea that it is due to some complex calculation, but i
I have this project that it's due in a few hours and I still
I have a DataGridView that is bound to a DataTable, it has a column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.