PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → Datedifference with native sql server
Datedifference with native sql server
Started by BARROS, Sep., 26 2019 1:44 PM - 4 replies
Registered member
5 messages
Posted on September, 26 2019 - 1:44 PM
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
Registered member
52 messages
Popularité : +3 (3 votes)
Posted on September, 26 2019 - 2:50 PM
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.
Registered member
5 messages
Posted on September, 26 2019 - 3:31 PM
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,8) < LEFT(SYSDATE,8)
)
ORDER BY
Dias DESC

--
Barros
Registered member
52 messages
Popularité : +3 (3 votes)
Posted on September, 26 2019 - 10:31 PM
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 !
Registered member
5 messages
Posted on October, 08 2019 - 6:57 PM
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