Showing posts with label oct. Show all posts
Showing posts with label oct. Show all posts

Monday, March 12, 2012

Script for Month End Day

Hi,
Can get script to get month end day for a given month like 31 for Oct, 30
for Nov.
Thanksdeclare @.dt datetime
set @.dt=getdate()
select [month]=month(dt),
[last day]=day(dt)
from (
select dateadd(m,1,@.dt)-day(@.dt)
)x(dt)
--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net
"DKRReddy" <dkrreddy@.hotmail.com> wrote in message
news:eRwDsgovDHA.2048@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Can get script to get month end day for a given month like 31 for Oct,
30
> for Nov.
> Thanks
>|||Thanks a lot.
"oj" <nospam_ojngo@.home.com> wrote in message
news:uGhKvjovDHA.3224@.tk2msftngp13.phx.gbl...
> declare @.dt datetime
> set @.dt=getdate()
> select [month]=month(dt),
> [last day]=day(dt)
> from (
> select dateadd(m,1,@.dt)-day(@.dt)
> )x(dt)
> --
> -oj
> RAC v2.2 & QALite!
> http://www.rac4sql.net
>
> "DKRReddy" <dkrreddy@.hotmail.com> wrote in message
> news:eRwDsgovDHA.2048@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> > Can get script to get month end day for a given month like 31 for
Oct,
> 30
> > for Nov.
> >
> > Thanks
> >
> >
>|||Hi
Another approach
select [month]=month(dt),
[last day]=day(dt)
from
(
select dateadd(month,datediff(month,'1900',getdate())+1,'1900')-1
) x(dt)
"DKRReddy" <dkrreddy@.hotmail.com> wrote in message
news:#zQkDZpvDHA.2472@.TK2MSFTNGP09.phx.gbl...
> Thanks a lot.
> "oj" <nospam_ojngo@.home.com> wrote in message
> news:uGhKvjovDHA.3224@.tk2msftngp13.phx.gbl...
> > declare @.dt datetime
> > set @.dt=getdate()
> >
> > select [month]=month(dt),
> > [last day]=day(dt)
> > from (
> > select dateadd(m,1,@.dt)-day(@.dt)
> > )x(dt)
> >
> > --
> > -oj
> > RAC v2.2 & QALite!
> > http://www.rac4sql.net
> >
> >
> > "DKRReddy" <dkrreddy@.hotmail.com> wrote in message
> > news:eRwDsgovDHA.2048@.TK2MSFTNGP10.phx.gbl...
> > > Hi,
> > > Can get script to get month end day for a given month like 31 for
> Oct,
> > 30
> > > for Nov.
> > >
> > > Thanks
> > >
> > >
> >
> >
>