TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
krunal pande
NA
101
28.1k
how to select first 15 days and last 15 days of every month
Nov 7 2017 3:48 AM
Hi team,
how to select first 15 days and last 15 days of every month of the year dynamically in sql server.
e.g
DECLARE @Month INTEGER
DECLARE @Year INTEGER
declare @midofmonth DATETIME
DECLARE @FirstDayOfMonth DATETIME
DECLARE @LastDayOfMonth DATETIME
DECLARE @16DayOfMonth DATETIME
DECLARE @Date1 datetime
SET @Year = YEAR(GETDATE())
SET @FirstDayOfMonth = dateadd(month, @month - 1, dateadd(year, @year - 1900, 0))
SET @Month = month(@FirstDayOfMonth)
SET @LastDayOfMonth = dateadd(month, @month, dateadd(year, @year - 1900, -1))
set @midofmonth=dateadd(month, 7, dateadd(year, @year - 1900, -17))
set @16DayOfMonth=Dateadd(d,16-DATEPART(d,getdate()),GETDATE())
Reply
Answers (
1
)
Start Index of In SQL
sql inner join query with specifc condition column