Live Webinar: Prompt Engineering: Skill Everyone Must Learn Today
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Get all Dates plus days name between two Date in SQL
WhatsApp
ravi rawat
Aug 11
2015
1.5
k
0
1
declare
@FromDate DATETIME
declare
@ToDate DATETIME
set
@FromDate =
'2015-01-01'
set
@ToDate =
'2015-12-31'
DECLARE
@TOTALCount
INT
SET
@FromDate = DATEADD(
DAY
,-1, @FromDate)
Select
@TOTALCount = DATEDIFF(DD, @FromDate, @ToDate);
WITH
d
AS
(
SELECT
top
(@TOTALCount) AllDays = DATEADD(
DAY
,
ROW_NUMBER() OVER (
ORDER
BY
object_id
),
REPLACE
(@FromDate,
'-'
,
''
)
)
FROM
sys.all_objects
)
select
DATENAME(DW, AllDays),
AllDays
From
d
where
AllDays
not
in
(
select
Cal_Date
from
NseData..Tbl_Holiday
)
sql dates
Up Next
Get all Dates plus days name between two Date in SQL