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)
 month and year

Author  Topic 

inbs
Aged Yak Warrior

860 Posts

Posted - 2011-12-04 : 04:45:00
i have 2 column Month and year,
i want to get the first date of month by this columns

month  Year  
1 2011
2 2011
3 2011


i want ot get:

month  Year    Date
1 2011 01-01-2011
2 2011 01-02-2011
3 2011 01-03-2011

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-04 : 04:47:45
assuming both the fields are of type integer, you can use like

SELECT [month],[Year],DATEADD(mm,[month]-1,DATEADD(yy,[Year]-1900,0)) AS [Date]
FROM table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

inbs
Aged Yak Warrior

860 Posts

Posted - 2011-12-04 : 04:56:27
thanks for quickly answer
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-04 : 05:04:18
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -