I’m wondering which DolphinDB function can calculate the time difference. For example, I have two values of DATETIME type, A and B. How can I calculate the time difference between A and B in years? The output should be like 0.5 years.
CodePudding user response:
Subtract variable B from A and you can get the difference in seconds. Then divide the result by 365 * 86400 (which is the total number of seconds in a day) to obtain the yearly difference. For example:
(2022.10.18T12:00:00 - 2022.04.18T00:00:00) \ (365 * 86400 )
The result is 0.50274, meaning the difference between the two dates is 0.50274 years.