SlideShare a Scribd company logo
1 of 1
--------------------------------------------------------------------------------
------------
DECLARE @startdate DATETIME
DECLARE @enddate DATETIME
DECLARE @id INT
DECLARE @totalcount INT
DECLARE @StartCounter INT = 1
DECLARE @BillDetailNormalized TABLE
(
ID INT,
StartDate DATETIME,
EndDate DATETIME
)
SELECT @totalcount = MAX(BillDetailID) from TempBillDetail
SET @StartCounter = 1
WHILE (@StartCounter <=@totalcount) --Total Records Loop
BEGIN
SELECT @startdate = StartDate,@enddate = EndDate FROM TempBillDetail WHERE
BillDetailID= @StartCounter
WHILE (DATEPART(MM,@startdate) <= DATEPART(MM,@enddate))-- Start Date and
EndDate Loop
BEGIN
IF (DATEPART(MM,@startdate) = DATEPART(MM,@enddate))
INSERT INTO @BillDetailNormalized VALUES (@StartCounter, @startdate,@enddate)
ELSE IF (DATEPART(MM,@startdate) < DATEPART(MM,@enddate))
INSERT INTO @BillDetailNormalized VALUES (@StartCounter,
@startdate,EOMONTH(@STARTDATE))
SET @startdate = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@startdate)+1,0)) +1
END
SET @StartCounter = @StartCounter + 1
END
--------------------------------------------------------------------------------
---------------
DECLARE @ServiceBeginKey DATE= '2013-11-01'
DECLARE @ServiceEndKey DATE = '2014-10-31'
SELECT * from ClientFiscalPeriods c WHERE ClientKey = 9
AND (C.FiscalPeriodCalendarEndDateKey >= @ServiceBeginKey)
AND (C.FiscalPeriodCalendarBeginDateKey <= @ServiceEndKey)
--------------------------------------------------------------------------------
---------------

More Related Content

Similar to Df

Metadata Matters
Metadata MattersMetadata Matters
Metadata Mattersafa reg
 
T sql denali code Day of .Net
T sql denali code Day of .NetT sql denali code Day of .Net
T sql denali code Day of .NetKathiK58
 
Seistech SQL code
Seistech SQL codeSeistech SQL code
Seistech SQL codeSimon Hoyle
 
as400 built in function- %MINUTES
as400 built in function- %MINUTESas400 built in function- %MINUTES
as400 built in function- %MINUTESaminem_mp
 
as400 built in function- %SECONDS
as400 built in function- %SECONDSas400 built in function- %SECONDS
as400 built in function- %SECONDSaminem_mp
 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemHitesh Mohapatra
 
Paging storedprocedure
Paging storedprocedurePaging storedprocedure
Paging storedprocedureseethalux
 
Organic Gardens SQL Database Schema By Christopher Kaczor
Organic Gardens SQL Database Schema By Christopher KaczorOrganic Gardens SQL Database Schema By Christopher Kaczor
Organic Gardens SQL Database Schema By Christopher KaczorChristopher Kaczor
 
as400 built in function- %HOURS
as400 built in function- %HOURSas400 built in function- %HOURS
as400 built in function- %HOURSaminem_mp
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1boedax
 
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)Insight Technology, Inc.
 
JKJ_T SQL project code samples
JKJ_T SQL project code samplesJKJ_T SQL project code samples
JKJ_T SQL project code samplesJeff Jacob
 
Set Focus SQL Portfolio
Set Focus SQL PortfolioSet Focus SQL Portfolio
Set Focus SQL Portfoliobrentbybee
 
Loopback.vhd
Loopback.vhdLoopback.vhd
Loopback.vhdsachindb9
 

Similar to Df (19)

Add invoice
Add invoiceAdd invoice
Add invoice
 
SAV
SAVSAV
SAV
 
Metadata Matters
Metadata MattersMetadata Matters
Metadata Matters
 
T sql denali code Day of .Net
T sql denali code Day of .NetT sql denali code Day of .Net
T sql denali code Day of .Net
 
Seistech SQL code
Seistech SQL codeSeistech SQL code
Seistech SQL code
 
MK1_Addendum
MK1_AddendumMK1_Addendum
MK1_Addendum
 
MariaDB Temporal Tables
MariaDB Temporal TablesMariaDB Temporal Tables
MariaDB Temporal Tables
 
as400 built in function- %MINUTES
as400 built in function- %MINUTESas400 built in function- %MINUTES
as400 built in function- %MINUTES
 
as400 built in function- %SECONDS
as400 built in function- %SECONDSas400 built in function- %SECONDS
as400 built in function- %SECONDS
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Paging storedprocedure
Paging storedprocedurePaging storedprocedure
Paging storedprocedure
 
Organic Gardens SQL Database Schema By Christopher Kaczor
Organic Gardens SQL Database Schema By Christopher KaczorOrganic Gardens SQL Database Schema By Christopher Kaczor
Organic Gardens SQL Database Schema By Christopher Kaczor
 
as400 built in function- %HOURS
as400 built in function- %HOURSas400 built in function- %HOURS
as400 built in function- %HOURS
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1
 
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
 
JKJ_T SQL project code samples
JKJ_T SQL project code samplesJKJ_T SQL project code samples
JKJ_T SQL project code samples
 
Writeable CTEs: The Next Big Thing
Writeable CTEs: The Next Big ThingWriteable CTEs: The Next Big Thing
Writeable CTEs: The Next Big Thing
 
Set Focus SQL Portfolio
Set Focus SQL PortfolioSet Focus SQL Portfolio
Set Focus SQL Portfolio
 
Loopback.vhd
Loopback.vhdLoopback.vhd
Loopback.vhd
 

Recently uploaded

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 

Recently uploaded (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 

Df

  • 1. -------------------------------------------------------------------------------- ------------ DECLARE @startdate DATETIME DECLARE @enddate DATETIME DECLARE @id INT DECLARE @totalcount INT DECLARE @StartCounter INT = 1 DECLARE @BillDetailNormalized TABLE ( ID INT, StartDate DATETIME, EndDate DATETIME ) SELECT @totalcount = MAX(BillDetailID) from TempBillDetail SET @StartCounter = 1 WHILE (@StartCounter <=@totalcount) --Total Records Loop BEGIN SELECT @startdate = StartDate,@enddate = EndDate FROM TempBillDetail WHERE BillDetailID= @StartCounter WHILE (DATEPART(MM,@startdate) <= DATEPART(MM,@enddate))-- Start Date and EndDate Loop BEGIN IF (DATEPART(MM,@startdate) = DATEPART(MM,@enddate)) INSERT INTO @BillDetailNormalized VALUES (@StartCounter, @startdate,@enddate) ELSE IF (DATEPART(MM,@startdate) < DATEPART(MM,@enddate)) INSERT INTO @BillDetailNormalized VALUES (@StartCounter, @startdate,EOMONTH(@STARTDATE)) SET @startdate = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@startdate)+1,0)) +1 END SET @StartCounter = @StartCounter + 1 END -------------------------------------------------------------------------------- --------------- DECLARE @ServiceBeginKey DATE= '2013-11-01' DECLARE @ServiceEndKey DATE = '2014-10-31' SELECT * from ClientFiscalPeriods c WHERE ClientKey = 9 AND (C.FiscalPeriodCalendarEndDateKey >= @ServiceBeginKey) AND (C.FiscalPeriodCalendarBeginDateKey <= @ServiceEndKey) -------------------------------------------------------------------------------- ---------------