How to get total number of days in current month
Show the first date of the current
month:-
select dateadd(dd,1-day(getdate()),getdate()) as FirstDateOfFirstMonth
Show the first date of the next
month:-
select dateadd(m,1,dateadd(dd,1-day(getdate()),getdate())) as FirstDayofSecondMonth
Show the total Number of days in the
current month:-
select datediff(dd, dateadd(dd,1-day(getdate()),getdate()),
dateadd(m,1,dateadd(dd,1-day(getdate()),getdate()))) as TotalNumberofday
select dateadd(dd,1-day(getdate()),getdate()) as FirstDateOfFirstMonth,
dateadd(m,1,dateadd(dd,1-day(getdate()),getdate())) as
FirstDayofSecondMonth
,datediff(dd, dateadd(dd,1-day(getdate()),getdate()),
dateadd(m,1,dateadd(dd,1-day(getdate()),getdate()))) as TotalNumberofday
0 comments:
Post a Comment