Forum Discussion
CGanabelle
9 years agoFrequent Visitor
Calculate difference between two date/time values
Hi everyone, I try to calculate the difference, in terms of time, between two datetime values. The problem is that when I use datediff, there is an error message : "In DATEDIFF function, the start d...
- 9 years ago
Yeah, I would also try to look for some inconsistencies in DB. I hope you will find it! :smileywink:
You are welcome Anabelle.
Regards.
Pavel
Anonymous
4 years agoNot applicable
How do i get the difference between two fruits from the previous day, see table below:
Current state:
| Date | Fruit | Quantity |
| 20/09/21 | Apple | 20 |
| 20/09/21 | Orange | 13 |
| 20/09/21 | Grapes | 30 |
| 21/09/21 | Apple | 18 |
| 21/09/21 | Orange | 9 |
| 21/09/21 | Grapes | 12 |
| 22/09/21 | Apple | 33 |
| 22/09/21 | Orange | 25 |
| 22/09/21 | Grape | 40 |
Desired State:
| Date | Fruit | Quantity | Previous Quantity | Difference |
| 20/09/21 | Apple | 20 |
| 20 |
| 20/09/21 | Orange | 13 |
| 13 |
| 20/09/21 | Grapes | 30 |
| 30 |
| 21/09/21 | Apple | 18 | 20 | -2 |
| 21/09/21 | Orange | 9 | 13 | -4 |
| 21/09/21 | Grapes | 12 | 30 | -18 |
| 22/09/21 | Apple | 33 | 18 | 12 |
| 22/09/21 | Orange | 25 | 9 | 16 |
| 22/09/21 | Grape | 40 | 12 | 28 |