i need to insert into a varchar field the current date, but in yyyy-mm-dd format. I thought I could do it using
datepart(yyyy,getdate()) & '-' & datepart(mm,getdate()) & '-' & datepart(dd,getdate())
or even
datepart(yyyy,getdate()) + '-' + datepart(mm,getdate()) + '-' + datepart(dd,getdate())
The first example returns 0 and the seconds adds up the values.
Can someone help?
datepart(yyyy,getdate()) & '-' & datepart(mm,getdate()) & '-' & datepart(dd,getdate())
or even
datepart(yyyy,getdate()) + '-' + datepart(mm,getdate()) + '-' + datepart(dd,getdate())
The first example returns 0 and the seconds adds up the values.
Can someone help?