sql server - converting Year and Month varchar to date -


i have table month , year varchar. realized big mistake. since getting complicated query way.

 year month productname        2013  11      acb       2013  11      cde 

i add column called date , store these year month date existing table

   year  month   productname     date    2013   11        acb          2013-11-01    2013   11        cde          2013-11-01 

is there way can columns of existing table ??

please let me know

convert month , year columns strings concatenated '-'s , add '-01' end. convert date.

update t set t.[date] = convert(date, convert(varchar(4),                         t.[year]) + '-' + convert(varchar(2), t.[month]) + '-01') table t 

this create date records in table.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -