Incorrect Parameter Count Difference Between Dates As A Date

On
  1. Incorrect Parameter Count Difference Between Dates As A Date Time
  2. Incorrect Parameter Count Difference Between Dates As A Date Book
  3. Incorrect Parameter Count Difference Between Dates As A Date 2016

Using CR 2008 I am using a start date and end date parameter to set the date range in the report selection criteria. Within the report I need to calculate the number of days that the report covers. I know how to write a datediff formula, but I need the datediff between two parameters and t seems that parameters cant be used in formulas. Instead of using one datetime value, it starts off with two values and calculates the interval between them. For example, here I calculate the interval between two dates held as attributes and return the answer in months: So if the two dates were 20170309 and 20170909 then the result would be 6 (or -6, depending on which way round the values were).

I get incorrect results when trying to find numeric difference between two dates:

Dates

Between 13.04.2016 and 28.04.2016 I shouldn't get that difference is 3 or 2 days..

I've tried to multiple combinations:

  • swap startDate.diff(endDate) with endDate.diff(startDate)
  • format('E') with something I've come up searching the SO

result: all the time I get that difference is 3 or 2 days.

What am I doing wrong? Thanks in advance.

Incorrect Parameter Count Difference Between Dates As A Date Time

wanttobeprofessional
1,0444 gold badges13 silver badges23 bronze badges
Miloš ĐakonovićMiloš Đakonović

Incorrect Parameter Count Difference Between Dates As A Date Book

1,7334 gold badges21 silver badges45 bronze badges

5 Answers

Incorrect Parameter Count Difference Between Dates As A Date 2016

Tweaking.com pro serial lookup. From the moment.js docs: format('E') stands for day of week. thus your diff is being computed on which day of the week, which has to be between 1 and 7.

From the moment.js docs again, here is what they suggest:

Here is a JSFiddle for your particular case:

Dani Akash
4,1601 gold badge15 silver badges35 bronze badges
dubesdubes
3,1891 gold badge23 silver badges35 bronze badges

the diff method returns the difference in milliseconds. Instantiating moment(diff) isn't meaningful.

You can define a variable :

and then use it like so :

Edit

actually, this is built into the diff method, dubes' answer is better

VonDVonD
3,8681 gold badge15 silver badges30 bronze badges

Here's how you can get the comprehensive full fledge difference of two dates.

Muneeb JSMuneeb JS
Sobhan DasSobhan Das
Sobhan DasSobhan Das

Not the answer you're looking for? Browse other questions tagged javascriptmomentjs or ask your own question.