I need to use the first day of previous month, can anybody help me with that please?
Thanks in advance!!
Printable View
I need to use the first day of previous month, can anybody help me with that please?
Thanks in advance!!
I can't use the function, I need it as aquery.
I have the last day of last month:
select dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate() ), 0))
can't figure out how to get the first day of last month....
select convert(datetime,left(Convert(varchar(8),dateadd(M ,-1,getdate()),112),6)+'01',112)
Another way:
SELECT DATEADD(m, DATEDIFF(m, 0, getdate()) -1, 0)
You can also do this to get the last date of last month:
SELECT DATEADD(m, DATEDIFF(m, 30, getdate()) -1, 30)
Thank you, that worked.