Date and time arithmetic

Have a suggestion for "Everything"? Please post it here.
Post Reply
anmac1789
Posts: 667
Joined: Mon Aug 24, 2020 1:16 pm

Date and time arithmetic

Post by anmac1789 »

This would change 'everything' especially for pinpointing duplicates. I know it's been said before that arithmetic with date and times is in development but I hope someone can shed some light how close are we to this ? Or has progress been made already with past updates?

Ticks vs. 100-nanoseconds which is more accurate for date and time differences?

[update] According to microsoft learn document, a single tick represents one hundred nanoseconds which equates to the time elapsed since 12:00:00 midnight, January 1, 0001 in the Gregorian calendar.
source: https://learn.microsoft.com/en-us/dotne ... ew=net-7.0
void
Developer
Posts: 16665
Joined: Fri Oct 16, 2009 11:31 pm

Re: Date and time arithmetic

Post by void »

Everything stores timestamps as FILETIMEs ( 100-nanosecond intervals since January 1, 1601 (UTC) )

Use eval: to perform arithmetic on FILETIMEs.

For example:

eval:$dm:/10000000!=$dc:/10000000
eval:
anmac1789
Posts: 667
Joined: Mon Aug 24, 2020 1:16 pm

Re: Date and time arithmetic

Post by anmac1789 »

void wrote: Wed Feb 22, 2023 11:31 pm Everything stores timestamps as FILETIMEs ( 100-nanosecond intervals since January 1, 1601 (UTC) )

Use eval: to perform arithmetic on FILETIMEs.

For example:

eval:$dm:/10000000!=$dc:/10000000
eval:
What if I want to have difference in seconds between date taken and date modified rather than (eval syntax)dm:!date-taken:
void
Developer
Posts: 16665
Joined: Fri Oct 16, 2009 11:31 pm

Re: Date and time arithmetic

Post by void »

Everything doesn't store timestamps in seconds.
Everything stores timestamps as FILETIMEs.

You'll need to convert FILETIMEs to seconds and then compare. (for example: /10000000 )



To compare date taken in seconds with date modified in seconds, please use:

eval:$date-taken:/10000000==$dm:/10000000



I'll consider adding a function to convert FILETIMEs to seconds as 10000000 is not an easy number to remember..
anmac1789
Posts: 667
Joined: Mon Aug 24, 2020 1:16 pm

Re: Date and time arithmetic

Post by anmac1789 »

void wrote: Thu Feb 23, 2023 2:44 am Everything doesn't store timestamps in seconds.
Everything stores timestamps as FILETIMEs.

You'll need to convert FILETIMEs to seconds and then compare. (for example: /10000000 )



To compare date taken in seconds with date modified in seconds, please use:

eval:$date-taken:/10000000==$dm:/10000000



I'll consider adding a function to convert FILETIMEs to seconds as 10000000 is not an easy number to remember..
eval:$date-taken:/10000000==$dm:/10000000

But this is comparing the filetimes not calculating the difference because there is an == sign
void
Developer
Posts: 16665
Joined: Fri Oct 16, 2009 11:31 pm

Re: Date and time arithmetic

Post by void »

Use column formulas

addcolumn:column1 column1:=$dm:/10000000-$date-taken:/10000000
Column 1 will show the difference in seconds.
meteorquake
Posts: 495
Joined: Thu Dec 15, 2016 9:44 pm

Re: Date and time arithmetic

Post by meteorquake »

Rather than a function per se, perhaps there could be a constant tosecs whose value is 10000000? then you'd just need yourtimestamp/tosecs or *tosecs for the reverse.

d
void
Developer
Posts: 16665
Joined: Fri Oct 16, 2009 11:31 pm

Re: Date and time arithmetic

Post by void »

I will consider a tosecs constant.

Thank you for the suggestion.
Post Reply