I am new to sql, I am in trouble with date formats I know I can use cast or convert function but I was looking to dateformat (we use format dd/mm/yy). I looks quite interesting function and very easy but there is a problem. IF I run this dataview
SELECT hotel, id, codicecliente, prodotto, CAST(REPLACE(numeros, ',', '.') AS decimal(7, 2)) AS numero, CAST(REPLACE(importos, ',', '.') AS decimal(7, 2)) AS importo,
CAST(datas AS datetime) AS data, puntovendita, DATEDIFF(day, '01/01/2000', datas) AS datav, isdate(datas) AS Expr1
FROM dbo.addebititmp
WHERE (isdate(datas) = 1)
it shows me about 15.000 records it is not showing all record with data with day more than 12 because system recognizes first 2 as month not day if I add SET DATEFORMAT dmy and run the following
SET DATEFORMAT dmy
SELECT hotel, id, codicecliente, prodotto, CAST(REPLACE(numeros, ',', '.') AS decimal(7, 2)) AS numero, CAST(REPLACE(importos, ',', '.') AS decimal(7, 2)) AS importo,
CAST(datas AS datetime) AS data, puntovendita, DATEDIFF(day, '01/01/2000', datas) AS datav, isdate(datas) AS Expr1
FROM dbo.addebititmp
WHERE (isdate(datas) = 1)
It shows correctly all 38.000 records but when I save the view system shows error: incorrect syntax near the keyword set. So I can run but not use it. I tried also with transact sql but if I creat a view with dateformat it does not save the dateformat and shows less records. Any suggestion? Thank You