Greetings!
I held off on posting here as I suspect there is a simple solution, however, I am embarrassed to say I’ve spent several days on this with no success. My coding experience is extremely limited in general, and pretty much non-existent when it comes to python.
My goal is to apply a conditional format to a date/time column that triggers when a specific number of days have passed since the value in that same column. I’ve attempted to employ the strptime and DATEVALUE functions as described in the documentation, however, it seems to me that both are intended to parse date components from a string field. As the column I’m referencing is already formatted as a date/time column, I’m simply stumped at how to formulate this.
As a workaround, I’ve attempted to create a column that returns the number of days since the reference (to then use the returned numeric value as a condition for the formatting), but I’ve not been able to achieve that either using the formula:
from datetime import datetime
delivery_date = datetime.strptime($Delivery_Date, '%Y-%m-%d %H:%M:%S')
current_date = datetime.now().date()
days_since_delivery = (current_date - delivery_date.date()).days
days_since_delivery
Using the above, the error returned is:
TypeError : strptime() argument 1 must be str, not datetime.datetime
A
TypeError
is usually caused by trying
to combine two incompatible types of objects,
by calling a function with the wrong type of object,
or by trying to do an operation not allowed on a given type of object.You tried to concatenate (add) two different types of objects:
a string (str
) anddatetime
.
I’ve honestly lost track of the various attempted methods I’ve tried, including the use of formulas that are working in Excel.
If anyone can offer some guidance, I’d sincerely appreciate it!
The referenced column is $Delivery_Date
I’m simply trying to achieve some type of visual indicator to draw attention to any rows for which 14 or more days have elapsed since the $Delivery_Date value.
I suspect the task would be more simple if the referenced column did not include the time, however, this data is being used to verify certified mail deliveries, so the timestamp is required.
Thanks in advance for any guidance!