|
-
SQl date calculation
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)
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|