Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Is it possible to get 1st day of the month based o

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2013-11-11 : 11:14:22
I am doing the following to get year and then month number from gl_accts table, is it possible to get 1st day of the month value as a new column.

If period is 3 and year is 2011, then the First Day_col, should have 20110301

select substring(DATA_SET_ID,7,10) YEAR,
month_number from GL_ACCTS

Thank you very much for the helpful info.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-11 : 11:36:47
[code]select dateadd(mm,month_number -1,dateadd(yy,substring(DATA_SET_ID,7,10)-1900,0)) AS MonthStartDate
from GL_ACCTS[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -