How to calculate the interval of days between dates of the same table but of different records

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
vsandoval
Posts: 13
Joined: 2023-01-14 15:51

How to calculate the interval of days between dates of the same table but of different records

Post by vsandoval » 2023-08-05 16:35

How to calculate the interval of days between dates of the same table but of different records
example.jpg
example.jpg (50.97 KiB) Viewed 4853 times
appgini screen.JPG
appgini screen.JPG (88.63 KiB) Viewed 4853 times
This is my code but it doesn't work for me


SELECT ABS(DATEDIFF(FECHA, LAG(FECHA) OVER (ORDER BY FECHA))) FROM `Clientes`;
WHERE `Clientes`.`ID`='%ID%'


mcvaidas
Posts: 29
Joined: 2019-04-14 17:45

Re: How to calculate the interval of days between dates of the same table but of different records

Post by mcvaidas » 2023-08-18 16:19

SELECT DATEDIFF( ( SELECT MIN(FECHA) FROM Clientes WHERE FECHA > ( SELECT FECHA FROM Clientes WHERE `Clientes`.`ID`='%ID%' ) ), ( SELECT FECHA FROM Clientes WHERE `Clientes`.`ID`='%ID%' ) ) AS date_diff FROM Clientes WHERE `Clientes`.`ID`='%ID%';

vsandoval
Posts: 13
Joined: 2023-01-14 15:51

Re: How to calculate the interval of days between dates of the same table but of different records

Post by vsandoval » 2023-08-19 15:54

The code works perfectly. It was exactly what I needed

thank you for your valuable help...!!!!

Post Reply