|
| Datedifference with native sql server |
| Iniciado por BARROS, 26,sep. 2019 13:44 - 4 respuestas |
| |
| | | |
|
| |
Miembro registrado 5 mensajes |
|
| Publicado el 26,septiembre 2019 - 13:44 |
Hi,
I'm new with WINDEV24 and I'm facing a difficulty to calculate datedifference in a query, using native sql server connector. There's a WL function for that, but only works with WFSQL datafiles. There's anybody able to help me on this? Thanks in advance.
-- Barros |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 52 mensajes |
|
| Publicado el 26,septiembre 2019 - 14:50 |
maybe the problem is with dateformat. Try to use "YYYYMMDD" or "DDMMYYYY" , "MMDDYYYY". If the problem is there, then you can use DateToString(myDate,maskDateSystem) so you use the correct format for each user. |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 5 mensajes |
|
| Publicado el 26,septiembre 2019 - 15:31 |
Hi Baltasar,
thank you for your answer. I'm getting this message error:

The message is very clear.
The query code is this:
SELECT DISTINCT Clientes.Nome AS Nome_Cl, Prestacoes.PrestacoesID AS EXPRESS_PrestacoesID, Prestacoes.DataIni AS Data, Prestacoes.Valor AS ValorDolares, Prestacoes.ValorKwanzas AS ValorKwanzas, Prestacoes.Estado AS Estado, Prestacoes.ContratosID AS EXPRESS_ContratosID, WL.DateDifférence(Prestacoes.DataIni,WL.Today()) AS Dias FROM Clientes, Contratos, Prestacoes WHERE Contratos.ContratosID = Prestacoes.ContratosID AND Clientes.Cliente = Contratos.Cliente AND ( Prestacoes.Estado = 1 AND LEFT(Prestacoes.DataIni, < LEFT(SYSDATE, ) ORDER BY Dias DESC
-- Barros |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 52 mensajes |
|
| Publicado el 26,septiembre 2019 - 22:31 |
| not sure, but maybe when you call sysdate function windev uses "DDMMYYYY", "DD/MM/YYYY" format instead of "YYYYMMYY" "YYYY/MM/DD" so you must check this first. If you call LEFT(SYSDATE,8) you want sql to return "20190926" but probably it's returning "2019/09/" or "26/09/20" so check this
good luck ! |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 5 mensajes |
|
| Publicado el 08,octubre 2019 - 18:57 |
HI Baltasar,
thanks for the tip. It didn't work. I found this solution: Replace SYSDATE by GETDATE(). But I can't use it with Query Editor. Thanks again.
-- Barros |
| |
| |
| | | |
|
| | | | |
| | |
|