I have a field named VALUE of VARCHAR2 type
The string is in this format: yyyy-mm-dd
Is it possible to change it to: dd-mm-yyyy
An then (again if possible) to convert it to date in this format?
What I have tried is:
SELECT convert(varchar, getdate(), 110)
but it’s only for the current time. Is there a way to do this?
Edit:
Here my code is:
select
p1.VALUE as Sdate
from Process p
LEFT JOIN PARAMETER p1 on p1.WP_ID=p.ID AND p1.NAME = 'Sdate'
WHERE p.TYPE = 'Marketing' and convert(varchar, convert(date,p1.value), 103) ='22.08.2012'
104will convert indd.mm.yyyyformatYour query should be:
See an example in this SQLFiddle.
Note that you should keep the column type as
DATEwhere you want to store dates. Also, always preferyyyyMMddformat.Have a look at CAST and CONVERT (Transact-SQL)