Sunday, 27 August 2017

How to get total number of days in current month

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

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...