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
 General SQL Server Forums
 New to SQL Server Programming
 Convert from varchar to Date

Author  Topic 

maraghy
Starting Member

1 Post

Posted - 2008-02-03 : 12:07:00
Hi,
Can any one help me in that case?
I have 2 colomns one have the month (1,2,3,4,....,12) and the other have the years (2007,2008,....)
I want to merge both in one date field MM/DD/YYYY and the day will always be '01'
Thank you
M.Maraghy

subrata4allfriends
Starting Member

24 Posts

Posted - 2008-02-03 : 12:43:23
Please go through the following sample............

SELECT CAST('01-'+COL1+'-'+COL2 AS DATETIME) FROM TABLE1

replace col1/ col2/ table1 as ur table and column name............
hope it will help u


Thanks & Regards,
4allfriends.

"Life is not a bed of roses."
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-10 : 22:15:01
make use of the function here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=22339


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -