{"id":34733,"date":"2014-10-31T08:22:09","date_gmt":"2014-10-31T13:22:09","guid":{"rendered":"https:\/\/mkncreations.com\/site\/?p=34733"},"modified":"2017-01-18T10:05:53","modified_gmt":"2017-01-18T15:05:53","slug":"tsql-how-to-find-previous-or-next-quarter-start-and-end-date","status":"publish","type":"post","link":"https:\/\/mkncreations.com\/site\/2014\/10\/tsql-how-to-find-previous-or-next-quarter-start-and-end-date\/","title":{"rendered":"TSQL &#8211; How to Find Previous or Next Quarter Start and End Date"},"content":{"rendered":"<p>If you would like to find the start and the end of the previous Quarter based of a date here is the t-sql code you will need:<\/p>\n<blockquote><p>\nDECLARE @yourdate DATETIME = GETDATE();<\/p>\n<p>SELECT DATEADD(qq, DATEDIFF(qq,0,@yourdate)-1, 0) AS [Previous_Quarter_Start]<br \/>\n, DATEADD(ms,-3,DATEADD(qq, DATEDIFF(qq,0,@yourdate), 0)) AS [Previous_Quarter_End_23_59]<br \/>\n, DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, @yourdate), 0)) AS [Previous_Quarter_End_00]\n<\/p><\/blockquote>\n<p>For next Quarter Start and End use this:<\/p>\n<blockquote><p>\nDECLARE @yourdate DATETIME = GETDATE();<\/p>\n<p>SELECT DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) + 1, 0) AS [Next_Quarter_Start]<br \/>\n, DATEADD (dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) +2, 0)) AS [Next_Quarter_End]\n<\/p><\/blockquote>\n<p>For getting the current Quarter start and end dates refer to this post:<br \/>\n<a href=\"https:\/\/mkncreations.com\/site\/2012\/10\/tsql-how-to-find-quarter-start-and-end-date\/\" title=\"https:\/\/mkncreations.com\/site\/2012\/10\/tsql-how-to-find-quarter-start-and-end-date\/\" target=\"_blank\">https:\/\/mkncreations.com\/site\/2012\/10\/tsql-how-to-find-quarter-start-and-end-date\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you would like to find the start and the end of the previous Quarter based of a date here is the t-sql code you&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,12],"tags":[175,174,142,143,75,76,77,50,49],"class_list":["post-34733","post","type-post","status-publish","format-standard","hentry","category-how_to","category-sql","tag-next","tag-nextquarter","tag-previous","tag-previousquarter","tag-quarter","tag-quarterend","tag-quarterstart","tag-sql-2","tag-tsql"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/34733"}],"collection":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/comments?post=34733"}],"version-history":[{"count":3,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/34733\/revisions"}],"predecessor-version":[{"id":671888,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/34733\/revisions\/671888"}],"wp:attachment":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/media?parent=34733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/categories?post=34733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/tags?post=34733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}