Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get current quarter start and end date from dashboard
#1
We will get date in yyyy-mm-dd format
Quarter indexing starts from zero

function current_quarter_start_date(quarter,year){
var aa=year+"-01-01";
 var bb=year+"-04-01";
 var cc=year+"-07-01";
 var dd=year+"-10-01";
if (quarter==1){return aa;}
else if (quarter==2){return bb;}
else if (quarter==3){return cc;}
else {return dd;}}

function current_quarter_end_date(quarter,year){
var aa=year+"-03-31";
 var bb=year+"-06-30";
 var cc=year+"-09-30";
 var dd=year+"-12-31";
if (quarter==1){return aa;}
else if (quarter==2){return bb;}
else if (quarter==3){return cc;}
else {return dd;}}

var date = new Date();
var year= date.getFullYear();
var current_quarter = Math.ceil((date.getMonth()+1) / 3);

var curqtr_start = current_quarter_start_date(current_quarter,year) );
var curqtr_end = current_quarter_end_date(current_quarter,year) );
Reply


Messages In This Thread
How to get current quarter start and end date from dashboard - by abhishek_acharya - 12-26-2022, 05:09 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)