if i use the query

SELECT iditem, CONVERT(char(20), dt, 105) FROM planeamento

it works just fine.. but in this case the dt (date) field is not recognised..

SELECT planeamento.iditem, idmodelo, item_planeamento.idproduto, item_planeamento.idpele, cor, ordemfabrico, qtd, CONVERT(char(20), dt, 105) FROM produto INNER JOIN item_planeamento ON produto.idproduto = item_planeamento.idproduto INNER JOIN  planeamento ON item_planeamento.iditem = planeamento.iditem WHERE planeamento.idfabrica = 51 AND alterado = 'FALSE' AND estado = NULL GROUP BY planeamento.iditem, produto.idModelo, item_planeamento.idProduto, item_planeamento.idPele, item_planeamento.cor, item_planeamento.ordemFabrico, item_planeamento.qtd, planeamento.dt

Can anyone see what's wrong?

thanks a lot for your help

It doesn't work because planeamento table is not in the FROM clause. Correct the query by specifying the planeamento as you did in other places CONVERT(char(20), planeamento.dt, 105)

hum, but my previous query was the same but without the convert, so, was just

SELECT planeamento.iditem, idmodelo, item_planeamento.idproduto, item_planeamento.idpele, cor, ordemfabrico, qtd, DT FROM .......

and it printed the dt fine, but int the wrong format, that's why i am trying to convert it.. i assumed that if dt prints well, why don't the convert works? i tried like you said:

CONVERT(char(20), planeamento.dt, 105)

but was the same..

thanks for your help!

>>but was the same..
You mean the convert was the same as without convert? If that is true then the 105 must be the wrong format specifier. I don't have the books so you will have to look up the format you want.

just found the problem.. i needed

CONVERT(char(20), planeamento.dt, 105) AS dt

everything was correct but i wasn't "giving" a name to the column i was converting

thanks a lot for your help

if i use the query

SELECT iditem, CONVERT(char(20), dt, 105) FROM planeamento

it works just fine.. but in this case the dt (date) field is not recognised..

SELECT planeamento.iditem, idmodelo, item_planeamento.idproduto, item_planeamento.idpele, cor, ordemfabrico, qtd, CONVERT(char(20), dt, 105) FROM produto INNER JOIN item_planeamento ON produto.idproduto = item_planeamento.idproduto INNER JOIN  planeamento ON item_planeamento.iditem = planeamento.iditem WHERE planeamento.idfabrica = 51 AND alterado = 'FALSE' AND estado = NULL GROUP BY planeamento.iditem, produto.idModelo, item_planeamento.idProduto, item_planeamento.idPele, item_planeamento.cor, item_planeamento.ordemFabrico, item_planeamento.qtd, planeamento.dt

Can anyone see what's wrong?

thanks a lot for your help

Hi Porsch

You are joining various tables. Are you sure that dt exists only in table planeamento? If not, dt must be qualified (as like as in group-by clause: planeamento.dt).

krs,
tesu

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.