Help me,please"Killer" <roninkaiser@.tiscali.it> wrote in message news:Sf_sc.21178$Wc.748257@.twister2.libero.it...
> How can i calculate the last day of the previous month?
> Help me,please
The last date of previous month:
SELECT CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP)
If you need the date normalized (time of 12:00AM), then:
SELECT CAST(CONVERT(CHAR(8),
CURRENT_TIMESTAMP - DAY(CURRENT_TIMESTAMP),
112) AS DATETIME)
--
JAG|||"Killer" <roninkaiser@.tiscali.it> wrote in message news:<Sf_sc.21178$Wc.748257@.twister2.libero.it>...
> How can i calculate the last day of the previous month?
> Help me,please
One way:
declare @.dt datetime
set @.dt = getdate()
select dateadd(dd, -datepart(dd, @.dt), @.dt)
select convert(char(8), dateadd(dd, -datepart(dd, @.dt), @.dt), 112)
Simon|||Simple date arithmatic. Take first of current month (ie. 5/1/2004)
and subtract 1 day.
No comments:
Post a Comment