I currently have a table with a column TimeID which holds the year and month as YYYYMM (i.e 201209 , for September 2012).
My task is to convert this number to YYYYMMDD with DD being the last day of whatever month it is; so for example 201209 becomes 20120930 or 201210 becomes 20121031.
urir10
Member
93 Points
225 Posts
SQL - How to calculate the last day of the month/?
Nov 19, 2012 06:26 PM|LINK
Hi All
Im really hoping i can get some help with this.
I currently have a table with a column TimeID which holds the year and month as YYYYMM (i.e 201209 , for September 2012).
My task is to convert this number to YYYYMMDD with DD being the last day of whatever month it is; so for example 201209 becomes 20120930 or 201210 becomes 20121031.
Any help will be much appreciated.
Thanks
spapim
Contributor
2446 Points
368 Posts
Re: SQL - How to calculate the last day of the month/?
Nov 19, 2012 06:37 PM|LINK
Hi,
Try something like this:
Hope this helps.
www.imobiliariasemsuzano.com.br
limno
All-Star
117314 Points
7997 Posts
Moderator
MVP
Re: SQL - How to calculate the last day of the month/?
Nov 19, 2012 06:40 PM|LINK
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
urir10
Member
93 Points
225 Posts
Re: SQL - How to calculate the last day of the month/?
Nov 19, 2012 09:05 PM|LINK
Thank You both!!! it worked great!