Document Date Placeholder choosing wrong date

I have a smart rule to file my cell phone bill. Part of the action is to rename it based on the date. I Change Name to “Consumer Cellular %documentDateSortableDate%”. The “Document Date” Placeholder has always seemed opaque to me, as there is no algorithm documented (that I can find) on how it is determined. It has always seemed to work, so I figured I would trust the black box.

Today, I downloaded a new bill and the date for the Document Date is “02/19/2023” for a March bill. I don’t know why the search bypassed dates on the first page like these

Bill Close Date 03/05/2025
Due Date 03/25/2025

only to choose an insignificant 2/19/2025 on page 3.

How does DocumentDate work? Is there a way to debug when it gives unexpected results?

1 Like

Development would have to comment but what’s the desired date?

It would be the Bill Close Date if for no other reason than because that has been the date chosen for the previous bills.

I can’t reproduce an issue with a very simple document. It could be related to the actual document’s contents.
What’s your smart rule look like?

Convert the document to plain text, does the text layer actually contain the expected dates? OCR issues can easily break the detection.

I have often noticed that the layout of a pdf is not always reflected in the order of items in the text layer. This seems to be particularly common where there are columns or boxes in the pdf. So something that comes later in the image of the pdf may turn up earlier in the text. I’ve often had a nightmare trying to extract continuous text from pdfs with columns, where the text layer jumps from column 1 to column 2, then back to column 1 again.

1 Like

I have seen that also. I primarily use Hazel as a pre-preprocessor before DEVONthink and that app provides a way to look at the actual PDF to help debug the rules. Indeed, the layout of the PDF is not always the same as the text layer. Life.

1 Like

Thaks to all for the replies. @BLUEFROG here is my smart rule

When the smart rule ran, the file was renamed to Consumer Cellular 2025-02-19. You can see that there is a 2/19 date in the text, but it is buried deep in this multipage document.

@cgrunenberg redacted PDF text below.

Remittance Section
Account Number
Due Date
Total Amount Due
Amount Enclosed

P.O. Box 371890
Pittsburgh, PA 15250-7890

107274959
03/25/2025
$88.67
$ ______________

Check here for change of address (see reverse for details)

Do Not Pay

[Address redacted]

Your credit card will be billed on your due date.

[Account number redacted]

Please detach and return above portion with your payment

Invoice Information
Account Number
Invoice Number
Bill Close Date
Due Date

[Account number redacted]
03/05/2025
03/25/2025

Important Messages

Summary of Charges
Balance Information
Previous Balance
Payments
Adjustments
Balance Forward

$88.67
-$88.67
$0.00
$0.00

Usage
Monthly Charges
Surcharge & Other Charges
Government Taxes & Fees

$0.00
$70.00
$12.91
$5.76

Current Charges

$88.67

Total Amount Due

$88.67

Payment Due 03/25/2025

HELPATTHETOUCHOFABUTTON
RI
SAl
l
yMedi
calAl
ertDevi
ce
Foral
i
mi
t
edt
i
me–addaFREEI
(
$89val
ue)t
oyouraccount
.Gett
hepeaceofmi
ndofhavi
ng
onet
ouchemer
gencyr
esponse24/7,365daysayear
.Servi
cei
s
onl
y$25/
mo.
888)7662586 t
Cal
l(
odayandusepr
omocodeFREEALLYor
l
ul
ar
.
com/2586.
vi
si
tConsumerCel

Mail Payment to: P.O. Box 371890, Pittsburgh, PA 15250-7890
Call: (888) 345-5510
Visit: www.ConsumerCellular.com
page 1

Change of Address: Update online at www.ConsumerCellular.com. If using this form, please check the box on reverse side.
Apt#:

Street Address:
City:

State:

Zip:

Home Number:
Credit Card Payment: Pay securely at www.ConsumerCellular.com or call (888) 345-5510 for no additional fee!
Or enter credit card information here:
Please charge my credit card this time only for: $
Please use my credit card for all future charges: (Monthly charge may vary depending on usage.)
Card Number:

Expiration Date:

Card Verification ID#:

Signature

Payments
TYPE
Auto pay
Total

DATE
02/25/2025

AMOUNT
-$88.67
-$88.67

RATE
36.30%
flat
flat

AMOUNT
$2.40
$0.04
$10.47
$12.91

RATE
5.00%
flat
flat

AMOUNT
$2.94
$0.36
$2.46
$5.76

Consumer Cellular Surcharges & Other Charges
DESCRIPTION
Fed USF Cellular: Federal
FCC Regulatory Fee (Wireless): Federal
Operational Compliance Fee
Total

Government Taxes & Fees
TYPE
Communications Service Tax (Wireless): VA
E-988 (Wireless): VA
E911 (Wireless): VA
Total

Monthly Summary
SERVICE NUMBER 
Monthly Charges
Unlimited Minutes
15GB / Unlimited Texts
Subtotal

BILLING
START DATE

BILLING
END DATE

02/06/2025
02/06/2025

03/05/2025
03/05/2025

Usage
Free In-Account Talk Minutes
Free Talk Minutes
Subtotal Talk Minutes

RATE

MINUTES /
OCCURRENCES

CHARGES
$15.00
$25.00
$40.00

0.00
0.00

1
58
59

$0.00
$0.00
$0.00

Free Messages
Subtotal Messaging Charges

0.00

32
32

$0.00
$0.00

Free Wireless Web Megabytes
Subtotal Wireless Web Megabytes

0.000

3,371
3,371

$0.00
$0.00

Total Usage Charges

$0.00

Total Charges for Service Number [Redacted]
SERVICE NUMBER [Redacted]
Monthly Charges
Additional Line Charge
Subtotal
Usage
Free In-Account Talk Minutes
page 2

$40.00

BILLING
START DATE

BILLING
END DATE

02/06/2025

03/05/2025

RATE

MINUTES /
OCCURRENCES

CHARGES
$15.00
$15.00

0.00

1

$0.00

Acount Name:
[Redacted]

Account Number:
[Redacted]

Bill Close Date:
03/05/2025

Due Date:
03/25/2025

Monthly Summary
MINUTES /
OCCURRENCES

CHARGES

0.00

53
54

$0.00
$0.00

Free Messages
Subtotal Messaging Charges

0.00

21
21

$0.00
$0.00

Free Wireless Web Megabytes
Subtotal Wireless Web Megabytes

0.000

1,656
1,656

$0.00
$0.00

SERVICE NUMBER [Redacted] cont'd

BILLING
START DATE

BILLING
END DATE

Usage cont'd
Free Talk Minutes
Subtotal Talk Minutes

RATE

Total Usage Charges

$0.00

Total Charges for Service Number [Redacted]
SERVICE NUMBER [Redacted]
Monthly Charges
Additional Line Charge
Subtotal

$15.00

BILLING
START DATE

BILLING
END DATE

02/06/2025

03/05/2025

Usage
Free Talk Minutes
Subtotal Talk Minutes

RATE

MINUTES /
OCCURRENCES

CHARGES
$15.00
$15.00

0.00

20
20

$0.00
$0.00

Free Messages
Subtotal Messaging Charges

0.00

81
81

$0.00
$0.00

Free Wireless Web Megabytes
Subtotal Wireless Web Megabytes

0.000

551
551

$0.00
$0.00

Total Usage Charges

$0.00

Total Charges for Service Number [Redacted]

$15.00

Talk Usage Details
CALL

DATE

TIME

CITY
CALLED

NUMBER
CALLED

FEATURE

MINUTES

OTHER
USAGE
TOTAL
MINUTE
CHARGES CHARGES CHARGES

2
2
1
2
1
1
1
18
1
2
1
1
1
6
2
1
1
6
1
1
2
2
2
1
59

$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00
$0.00

[Redacted]

02/06/2025 12:00PM Incoming
3
02/07/2025 03:23PM Incoming
6
02/19/2025 11:54AM Incoming
11
02/20/2025 03:12PM Incoming
12

Bill Close Date:
03/05/2025

Due Date:
03/25/2025

Wireless Web Usage Details

[Redacted]

#

Account Number:
[Redacted]

#

DATE

TIME

MEGABYTES

CHARGES

  • Why are you using so many event triggers? Especially, Every Minute is excessive in this instance.

  • What OS are you running? The text layer isn’t the same on Sequoia and Ventura, for example.


One option is for the example you gave is…

The date field is…

*
$[0-9]*

using Option-Return to enter a multi-line value.


A bit more oblique but likely more accurate option is a regular expression, e.g., …

So this looks for a nine-digit string at the end of a line then captures 2 digits, 2 digits, and 4 digits, ignoring the forward slashes between them.

(?m) allows use of anchors ^ and $ (optional but good to know)

  • Why are you using so many event triggers? Especially, Every Minute is excessive in this instance.

True, that was put there while debugging and never removed. I do like the dopamine hit of seeing it appear almost immediately as well as the Reaganism “Trust, but verify” :wink:

  • What OS are you running? The text layer isn’t the same on Sequoia and Ventura, for example.

I’m running Sequoia 15.3.2.

One option is for the example you gave is

Ahh, now I understand what this field does from the docs!! I should have read the example more closely in the DT manual! This allows the matching to behave in a manner similar to Hazel.

If you want the rush, use On Import and let DEVONthink breathe a little :wink:

Ahh, now I understand what this field does from the docs!! I should have read the example more closely in the DT manual! This allows the matching to behave in a manner similar to Hazel.

Glad it helped. :slight_smile:

To you and future readers:
Bear in mind, this is only a prescription for this document (or future invoices from this vendor). It may work for others as well, but as there’s no “standard invoice”, variations would likely be required.

At least when using only this text layer instead of your PDF document I get the expected date (03/05/2025). Does reimporting the document make a difference?

@cgrunenberg unfortunately, I have already modified the rule, so I can’t say for sure. The sage advice of @BLUEFROG resulted in this which seems to have worked very well

The scan string is

Bill Close Date:
*
1 Like

I prefer the “sortable newest document date” placeholder rather than “sortable document date”. It more reliably gets the date I want. It would certainly solve the issue with your Consumer Cellular bills.

That is also an option, but it’s not quite what I need. The PDF text says this

Bill Close Date
Due Date
[Account number redacted]
03/05/2025
03/25/2025

So, the newest date is when the bill is due, but I want the end of the statement period.

Give it a try. The newest date reliably finds the statement date, not the due date. It’s like magic!

1 Like

Hmm, I dislike magic. Maybe I am having a disconnect on what the Newest date means. From the DEVONthink VERSION 3.9.8 DOCUMENTATION

Newest/Oldest Document Date: The newest or oldest date detected in the document. For PDFs, only the first four pages are used. newestDocumentDate… and oldestDocumentDate…

The Due Date (3/25/2025) is the newest date, newer than the Bill Close Date (3/05/2025). What am I missing?

Jim or Christian would have to answer that definitively. But just give it a try and see if it works for you.