-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support date math with mutate2 #162
Comments
I do some tests and believe the package doe not support date computation. |
According to https://github.com/Knetic/govaluate/blob/master/MANUAL.md#types it converts dates to float64 automatically. Hence, it should be able to do some math with it. And it works, indeed:
But providing two dates does not seem to work because of some inconsistencies. |
So, we can operate on the basis of adding/subtracting 'seconds' from a date. The above operation gave us 1629842400.00, which the Epoch Converter at https://www.epochconverter.com/ shows as 2021-08-24 in GMT. The Excel formula to convert Unix timestamp to Date at https://exceljet.net/formula/convert-unix-time-stamp-to-excel-date also gives us 2021-08-24. But, in the previous post one day was subtracted from 2021-08-26, which should be 2021-08-25. Then why is the Unix timestamp to date conversion of the result of operation showing 2021-08-24 ? Being able to calculate the difference in days between two dates directly in csvtk would indeed be very useful. |
The following is done using miller's If we have a csv file
Then the following command:
gives:
Something similar may be implemented for |
Sorry I can't make a promise I'll add this. Because |
I've noticed one custom function Usage: https://exceljet.net/excel-functions/excel-datedif-function |
Let's leave this to v0.25.0, after finishing #172 |
@san-r,
The date math returns a |
Currently,
mutate2
accepts date strings and can do some math with it, i.e. subtracting seconds but it does not return date-formatted strings (see #159 (comment)).Even if it can do some math if the expression contains a numeric value, it cannot compute the difference (for instance) between dates; although, it detects the date types:
It can compare dates, already:
The text was updated successfully, but these errors were encountered: