cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with TimeRange.create

Alexander_Blasl
Participant
0 Kudos

Hello,

I wanted to create a Day-TimeRange, but it got my values completely wrong. Any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

JefB
Active Contributor
0 Kudos

JavaScript counts months from 0 to 11, so:

  • January = 0
  • December = 11

Perhaps 12 makes the code go to January in the next year

Alexander_Blasl
Participant
0 Kudos

Awesome! Many thanks!!!!

Answers (1)

Answers (1)

avsalynin
Active Contributor
0 Kudos

ablasl88

I just tried it too and it strangely increments the month by +1 for some reason
var l_date1 = new Date(2022,0,20);
var l_date2 = new Date(2022,0,25);
var range = TimeRange.create(TimeRangeGranularity.Day, l_date1,l_date2);
console.log(range);

at the same time, with the year and the day, everything is in order with me

var l_date1 = new Date(2022,1,17);
var l_date2 = new Date(2022,2,8);
var range = TimeRange.create(TimeRangeGranularity.Day, l_date1,l_date2);
console.log(range);
Alexander_Blasl
Participant
0 Kudos

avsalynin I got the same issues. But the things get more irritating if you change the years. Try this out:

var l_date1 = new Date(2021,12,17);
var l_date2 = new Date(2022,2,18);
var range = TimeRange.create(TimeRangeGranularity.Day, l_date1,l_date2); 

Is there any solution for this?