当前位置:网站首页>Get start date and end date for all quarters of the year
Get start date and end date for all quarters of the year
2022-06-12 10:29:00 【Zi Jiao】
/*************************************
* Get the four quarters of the specified year
* getAllQuarters(new Date().getFullYear()+'-01-01');
* @param year string Year to query
*************************************/
function getAllQuarters(year) {
var d = new Date(year) //Pass your financial year's start date
, q1Start = new Date(d.getFullYear(), d.getMonth(), 1)
, dummy1 = new Date(d.getFullYear(), d.getMonth(), 1)
, dummy5 = new Date(d.getFullYear(), d.getMonth(), 1)
, q1End = new Date(dummy1.setMonth(dummy1.getMonth()+3))
, q1FinalEnd = new Date(dummy5.setMonth(dummy5.getMonth()+3))
;
q1FinalEnd.setSeconds(q1End.getSeconds()-1);
var q2Start = new Date(q1End.getFullYear(),q1End.getMonth(), 1)
, dummy2 = new Date(q1End.getFullYear(),q1End.getMonth(), 1)
, dummy6 = new Date(q1End.getFullYear(),q1End.getMonth(), 1)
, q2End = new Date(dummy2.setMonth(dummy2.getMonth()+3))
, q2FinalEnd = new Date(dummy6.setMonth(dummy6.getMonth()+3))
;
q2FinalEnd.setSeconds(q2End.getSeconds()-1);
var q3Start = new Date(q2End.getFullYear(),q2End.getMonth(), 1)
, dummy3 = new Date(q2End.getFullYear(),q2End.getMonth(), 1)
, dummy7 = new Date(q2End.getFullYear(),q2End.getMonth(), 1)
, q3End = new Date(dummy3.setMonth(dummy3.getMonth()+3))
, q3FinalEnd=new Date(dummy7.setMonth(dummy7.getMonth()+3))
;
q3FinalEnd.setSeconds(q3End.getSeconds()-1);
var q4Start = new Date(q3End.getFullYear(),q3End.getMonth(), 1)
, dummy4 = new Date(q3End.getFullYear(),q3End.getMonth(), 1)
, dummy8 = new Date(q3End.getFullYear(),q3End.getMonth(), 1)
, q4End = new Date(dummy4.setMonth(dummy4.getMonth()+3))
, q4FinalEnd = new Date(dummy8.setMonth(dummy8.getMonth()+3))
;
q4FinalEnd.setSeconds(q4End.getSeconds()-1);
return {
'q1Sta':dateFormat(q1Start),
'q1End':dateFormat(q1FinalEnd),
'q2Sta':dateFormat(q2Start),
'q2End':dateFormat(q2FinalEnd),
'q3Sta':dateFormat(q3Start),
'q3End':dateFormat(q3FinalEnd),
'q4Sta':dateFormat(q4Start),
'q4End':dateFormat(q4FinalEnd)
}
}
边栏推荐
- How to play the 2022 Taobao 618 Super Cat Games? Playing skills of 2022 Taobao 618 Cat Games
- Introduction to encoding formats (ASCII, Unicode and UTF-8)
- PostgreSQL uses stored procedures to splice multiple tables and query data
- [CEGUI] resource loading process
- CentOS 7 installing MySQL 8
- 不需要安装防毒软件的系统Chromebook
- JVM (V) Virtual machine class loading (parental delegation mechanism)
- MYSQL用户与权限管理,角色管理
- How PLC constructs shift function block (FC) by itself
- CTF freshman cup PHP deserialization question - EzPop
猜你喜欢

Leetcode2154. 将找到的值乘以 2(二分查找)

MQTT 协议中文版
![[CEGUI] log system](/img/5d/c8f76194b1ae2a62d3f5a1e84a5603.jpg)
[CEGUI] log system
![[926. flip the string to monotonic increment]](/img/fa/1838405693aa0998694d4895a611c2.png)
[926. flip the string to monotonic increment]

Mqtt protocol Chinese version

How to refund the pre-sale deposit of JD 618 in 2022? Can JD 618 deposit be refunded?

远程桌面不能复制粘贴解决办法
![Data processing and visualization of machine learning [iris data classification | feature attribute comparison]](/img/a3/1d181b9dd5268e13cc276a78862d1f.png)
Data processing and visualization of machine learning [iris data classification | feature attribute comparison]

Chapter 3 search
![[MySQL] index invalidation and index optimization](/img/af/9ed540aab764f4962ccc9bbfe406f3.jpg)
[MySQL] index invalidation and index optimization
随机推荐
ID obfuscation
The solution of Lenovo notebook ThinkPad t440 WiFi unable to connect to the Internet
A few secrets - a special day
浅谈调和形状上下文特征HSC对3DSC的改进
Student management system
ServletContext object
Win10 professional edition user name modification
Getting started with cloud API basics -- basic knowledge of picgo writing plug-ins
How high can C language reach by self-study alone?
reflex
一测两三年,记测试交流经验的一些感想
Raw socket usage
How to play the 618 super cat games on Taobao? Here comes the introduction to the overall activities of the Super Cat Games
How to play the 2022 Taobao 618 Super Cat Games? What are the strategies for the Super Cat Games
Solution to the problem that the applet developer tool cannot input simplified Chinese
Mobile terminal commissioning
Machine learning is not something you can use if you want to use it
Jump to wechat in app and open wechat
PHP wechat payment V3 interface
Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)