How to extract timestamp into custom columns ?

Discussion related to "Everything" 1.5 Alpha.
Post Reply
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

How to extract timestamp into custom columns ?

Post by anmac1789 »

hello everyone, how do I extract certain time format from a timestamp property and display it in a custom column ? For example, I want to put the hour from date taken in custom column1 and the hour from date modified into custom column2 and format the custom column as hh:mm or hh:mm:ss ?
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

addcolumn:a;b a:=formatfiletime($date-taken:,"HH:mm:ss") b:=formatfiletime($date-modified:,"HH:mm:ss")

formatfiletime()
Time Format
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Fri Nov 03, 2023 3:16 am addcolumn:a;b a:=formatfiletime($date-taken:,"HH:mm:ss") b:=formatfiletime($date-modified:,"HH:mm:ss")

formatfiletime()
Time Format
what about calculating the difference between the date taken and date modified in a custom column formatted as "hh:mm:ss" ??
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

addcolumn:a a:=formatduration($date-modified:-$date-taken:,"[hh]:mm:ss")

formatduration()
Duration Syntax
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Fri Nov 03, 2023 3:23 am addcolumn:a a:=formatduration($date-modified:-$date-taken:,"[hh]:mm:ss")

formatduration()
Duration Syntax
There seems to be a mistake in calculating the duration. Please see the screenshot:

Screenshot 2023-11-02 233243.jpg
Screenshot 2023-11-02 233243.jpg (123.47 KiB) Viewed 14407 times
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

The result is truncated.

00:00:02 is correct.

00:00:02.1700000 is the true value.

What value are you expecting?

The folder doesn't have a date taken value.



To show the ceiling value, please try the following search:

addcolumn:a a:=formatduration($date-modified:-$date-taken:+9999999,"[hh]:mm:ss")



To show the full time difference in 100-nano-seconds:

addcolumn:a a:=formatduration($date-modified:-$date-taken:,"[hh]:mm:ss.SSSSSSS")
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Fri Nov 03, 2023 3:37 am The result is truncated.

00:00:02 is correct.

00:00:02.1700000 is the true value.

What value are you expecting?



To show the ceiling value, please try the following search:

addcolumn:a a:=formatduration($date-modified:-$date-taken:+9999999,"[hh]:mm:ss")



To show the full time difference in 100-nano-seconds:

addcolumn:a a:=formatduration($date-modified:-$date-taken:,"[hh]:mm:ss.SSSSSSS")
I'm expecting the exact time difference between the seconds or milliseconds...u know like doing actual math lol (without rounding or truncation). Where did you get 00:00:02.1700000 ???
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

From the focused file:

Code: Select all

date-modified: 06:03:31.0000000 - 
date-taken:    06:03:28.8300000 =
difference:    00:00:02.1700000
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Fri Nov 03, 2023 3:44 am From the focused file:

Code: Select all

date-modified: 06:03:31.0000000 - 
date-taken:    06:03:28.8300000 =
difference:    00:00:02.1700000
to show it in minutes and seconds..it would be [mm]:ss.SSSSSSSSSS or [mm]:[ss.SSSSSSSSSS] ?

Why does it do something like this ? lol

Screenshot 2023-11-02 235101.jpg
Screenshot 2023-11-02 235101.jpg (120.98 KiB) Viewed 14379 times
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

[mm]:ss.SSSSSSS
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

The maximum number of SSS's is 7

I'll make this a hard cap in the next alpha update..
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Fri Nov 03, 2023 3:57 am The maximum number of SSS's is 7

I'll make this a hard cap in the next alpha update..
Thank you I was wondering why it's repeating like that. Is there a specific reason why it's 7 S's ?
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

It's just repeating the same 7 digits over and over.

There's a maximum of 7 decimal places for 100-nano-second FILETIMEs when shown as seconds.
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Fri Nov 03, 2023 4:04 am It's just repeating the same 7 digits over and over.

There's a maximum of 7 decimal places for 100-nano-second FILETIMEs when shown as seconds.
I see...can you also add AM/PM because when a date says 02:20:31.0000000 I dont know if it's 2 AM or 2 PM. Also, there is one file for which the time difference doesn't make sense to me. Please see the the screenshot highlighting the particular file of interest.

Screenshot 2023-11-03 004917.jpg
Screenshot 2023-11-03 004917.jpg (110.92 KiB) Viewed 14365 times

140 days, 4 hours, 43 minutes, 54 seconds, 0.2002273 ms (shown as 100 ns seconds)

If you add 140 days to Aug 18, 2022 it is Jan 5, 2023. If you add 4 hours to 02:20:31.0000000 then it will be 06:20:31.0000000 PM. If you add 43 minutes then it will be 06:(20+43=63 min --> 63 min - 60 min = 1 hour, 3 min):31.0000000 PM --> 07:03:31.0000000 PM. If you add 54.2002273 seconds to 07:03:31.0000000 PM then it will be 07:03:(31.0000000 s + 54.2002273 s = 85.2002273 s - 60 s = 1 min, 25.2002273 s) PM --> 07:04:32.25.2002273 PM. Why is this showing the wrong time ? or did I make a mistake in my calculations ?
Last edited by anmac1789 on Fri Nov 03, 2023 5:15 am, edited 1 time in total.
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

I see...can you also add AM/PM because when a date says 02:20:31.0000000 I dont know if it's 2 AM or 2 PM
It doesn't make any sense to show AM/PM on time differences.


if you compare the difference between the date taken and date modified of the highlighted file, the hour is off by 1
Day light savings occurred during this period.

Everything uses FILETIMEs internally for date modified and date taken.

FILETIMEs are 100-nanosecond intervals since January 1, 1601 (UTC).



To view the FILETIMEs, include the following in your search:

addcolumn:a;b;c a:=$date-modified: b:=$date-taken: c:=$date-modified:-$date-taken: a-label:="Date Modified FILETIME" b-label:="Date Taken FILETIME" c-label:="Time difference in 100-nano-seconds"
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

To view the data/times as UTC:

addcolumn:a;b;c a:=FORMATFILETIMEUTC($date-modified:) b:=FORMATFILETIMEUTC($date-taken:) c:=formatduration($date-modified:-$date-taken:,"[d]:hh:mm:ss.SSSSSSS") a-label:="Date Modified UTC" b-label:="Date Taken UTC" c-label:="Time difference in 100-nano-seconds"

You will see the correct time difference here.



FORMATFILETIMEUTC()
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Fri Nov 03, 2023 5:15 am
I see...can you also add AM/PM because when a date says 02:20:31.0000000 I dont know if it's 2 AM or 2 PM
It doesn't make any sense to show AM/PM on time differences.
Oh, I only mean to show AM/PM for the expanded time format hh:mm:ss.SSSSSSS not the time difference
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

Time Format

hh:mm:ss.SSSSSSS tt



To use 24 hour time:

HH:mm:ss.SSSSSSS
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Fri Nov 03, 2023 5:17 am To view the data/times as UTC:

addcolumn:a;b;c a:=FORMATFILETIMEUTC($date-modified:) b:=FORMATFILETIMEUTC($date-taken:) c:=formatduration($date-modified:-$date-taken:+9999999,"[d]:hh:mm:ss.SSSSSSS") a-label:="Date Modified UTC" b-label:="Date Taken UTC" c-label:="Time difference in 100-nano-seconds"

You will see the correct time difference here.
I see the correct time difference only when the date taken and date modified are both observing DST or both not observing DST, if the date taken is observing DST and date modified is not, the time will be off by 1 hour and vice versa
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

format_duration not showing exact difference

Post by anmac1789 »

For the highlighted file time difference between date taken and date modified, why is it -0 ? it should be 2 seconds. Please see screenshot

Screenshot 2023-11-11 204844.jpg
Screenshot 2023-11-11 204844.jpg (1.03 MiB) Viewed 14081 times
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

Formatting with s.SSSSSSSSSSSSSSSSSSSS will be fixed in the next alpha update.

For now, please try formatting with:

s.SSSSSSS

-or-

avoid the formatting:

column1:=$date-modified:-$date-taken:
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Sun Nov 12, 2023 1:55 am Formatting with s.SSSSSSSSSSSSSSSSSSSS will be fixed in the next alpha update.

For now, please try formatting with:

s.SSSSSSS

-or-

avoid the formatting:

column1:=$date-modified:-$date-taken:
Why doesn't ss:SSSSSSS work ? isnt the 7 long S's suppose to represent 100 nanoseconds ?
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

SSSSSSS is a quirk.
It shows the fraction of seconds. (upto 100 nanosecond resolution)
It should only ever be used after s or ss

The following should work as expected:

ss:SSSSSSS

shows seconds with a leading zero
shows fraction of seconds after ':'

What is shown for you?
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

ss:SSSSSSS shows somwthing like 01:0000000 but ss.SSSSSSS shows the exact 100 nanosecond resolution
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

anmac1789 wrote: Sun Nov 12, 2023 3:57 am ss:SSSSSSS shows somwthing like 01:0000000 but ss.SSSSSSS shows the exact 100 nanosecond resolution
Also, is it possible to define a less than and greater than < > range for the format duration custom column ?
I think it would be very useful if math inequalities could be used with search properties. For example

search all files which have difference between date taken and date modified is greater than 1 second...(or 2 seconds, 1 hour, 12 hrs..etc)
(date-taken:<date-modified:)>00:00:01 -- greater than 1 sec
(date-taken:<date-modified:)<=01:00:00 --less than or equal to 1 hour difference
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

Greater than 1 second:
$date-modified:-$date-taken:>10000000

Less than or equal to 1 hour:
$date-modified:-$date-taken:<=10000000*60*60
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

thanks void and does the subtraction need to be in brackets ?
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

no.
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

Everything 1.5.0.1360a will now correctly format filetimes when using 3 S or more.

For example:

ss.SSSSSSSSSS

Zeros are always shown after the 7th decimal place.



Added a FILETIMETOLOCALFILETIME() formula function.
This might be useful to perform arthritic on filetimes in local time.

For example:
addcolumn:a a:=FORMATDURATION(FILETIMETOLOCALFILETIME($date-modified:)-FILETIMETOLOCALFILETIME($date-taken:),"[d]:hh:mm:ss.SSSSSSS")
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

void wrote: Thu Nov 16, 2023 7:40 am Everything 1.5.0.1360a will now correctly format filetimes when using 3 S or more.

For example:

ss.SSSSSSSSSS

Zeros are always shown after the 7th decimal place.



Added a FILETIMETOLOCALFILETIME() formula function.
This might be useful to perform arthritic on filetimes in local time.

For example:
addcolumn:a a:=FORMATDURATION(FILETIMETOLOCALFILETIME($date-modified:)-FILETIMETOLOCALFILETIME($date-taken:),"[d]:hh:mm:ss.SSSSSSS")
Thank you for this void it's very helpful
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: How to extract timestamp into custom columns ?

Post by anmac1789 »

I just want to come back to this topic but using the following format duration still displays the long millisecond resolution repeatedly:

column2:=formatduration($date-modified:-$date-taken:,"[d]:hh:mm:ss.SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS")

Screenshot 2024-07-20 133437.png
Screenshot 2024-07-20 133437.png (256.42 KiB) Viewed 10297 times
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to extract timestamp into custom columns ?

Post by void »

This is expected output.

What values are you expecting?

Timestamps only have a resolution of 100-nanoseconds ( [d]:hh:mm:ss.SSSSSSS )
Any extra SSS's will always be zero.
Post Reply