0
votes

I switched from date_select to jQuery UI Datepicker and when I am trying to subtract the dates to get the number of days between those days I am getting the following error.

enter image description here

The date format for date_select is year/month/day however the format for the jQuery Datepicker is month/day/year. How can I combat this issue and still use Datepicker?

2

2 Answers

1
votes

You can rewrite it like this:

Date.strptime(@pdform.date_finish, "%m/%d/%Y") - Date.strptime(@pdform.date_start, "%m/%d/%Y")

For my tests on console, this should work. Hope this helps, good luck!

Edit: That works for the different date format, but the error shown is about nil classes, so maybe there's something wrong with your values... should check that first!

0
votes

Try doing a null check before the subract operation. something like

if @pdform.date_finish.present && @pdform.done_start.present && //your opertaion

It clearly states you have a nil error