question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Date range not working properly

See original GitHub issue

For this exemple, use START DATE and END DATE

START DATE : 2009-11-01 END DATE : 2010-10-01

Date format => YYYY-MM-DD

https://danfo.jsdata.org/api-reference/series/series.dt.day

Code like in documentation :

let dataDays = new dfd.date_range({"start": startDate, "end":endDate}); console.log("### DAYS BETWEEN DATES WITH DANFO DATE RANGE : ", dataDays.length);

Code result is bad => 364


expected Result => 335

try with this url => https://www.timeanddate.com/date/durationresult.html?d1=1&m1=11&y1=2009&d2=1&m2=10&y2=2010&ti=on


Proof with date-fns

`const { addDays, addMonths, differenceInDays, differenceInMonths } = require(‘date-fns’);

const dateRange = function (startDate, endDate, interval) { // D = Days if (interval === ‘D’) { const days = differenceInDays(endDate, startDate); return […Array(days+1).keys()].map((i) => addDays(startDate, i)); } // M = Months if (interval === ‘M’) { const months = differenceInMonths(endDate, startDate); return […Array(months+1).keys()].map((i) => addMonths(startDate, i)); } }

let daysBetweenDates = dateRange(new Date(startDate), new Date(endDate), ‘D’); console.log(‘### DAYS BETWEEN DATES WITH CUSTOM DATE RANGE :’, daysBetweenDates.length); `

Code result ok => 335


Thank’s for your help 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolashedoirecommented, Mar 3, 2021

@steveoni What do you think?

Yes it’s a good idea ! Dates are always a problem in programming …

0reactions
steveonicommented, Mar 8, 2021

@nicolashedoire issue now fixed in #139

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Data Studio Date Range Control is not working
Google Data Studio Date Range Control is not working · 1. The default date range is set at custom · 2. The Date...
Read more >
Datatables date range filter not working properly
I'm trying to add a date range filter on a Datatable but im not able to get it working properly. The date comes...
Read more >
Date Range Not Working - Looker Studio Community
The only problem is when I put the date range, all the displays become "no data". I already try to browse around to...
Read more >
No data showing and using the Date Range control - YouTube
... no data showing in your Data Studio report that uses the Analytics Canvas Partner Data Connector, and how to use the Date...
Read more >
Date Range Filter Not Working | WordPress.org
I need to be able to search within range of dates, but the filter is consistently returning “0” results. I've tried as many...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found