Display number of days from a records 'created_date' to the current date

Hey all,

I’m trying to display the number of days on a record since it was created but can’t seem to find a logical way to do this with conditions or components. Appreciate any pointers!

hello @mgaussie
why you dont use formatter ?

Would you mind elaborating a little for me? I’ve looked through formatter / conditions and can’t seem to find a solution!

I’m not on Wappler now, but in with the dynamic data bindings tool if you’re working with a date field (like a created date) there are a bunch of metrics you can you to to date calculations.

You can add dates, subtract time etc. There might be one that is days until.

If not you could achieve the same result using today’s date from the app connect date element and get the number you’re after. I.e. today’s date minus created date

1 Like

With custom SQL
SELECT ( DATEDIFF( '2011-06-06 12:12:12', '2011-05-05 10:10:10' ) )

Logic
Now - yourdatefield

1 Like

Thank you @Phili_J - I hadn’t seen this specific element, so did a search for it based on your comment and found it. Haven’t got it working yet, but optimistic this will solve it, thank you!

Thank you @s.alpaslan - custom SQL’s are a little beyond me right now, but I’ll get there. I appreciate you writing that for me!

No worries. Sometimes with the things you might need to use the ‘convert to date’ function first, then use the maths functions.

Or at least use the format date function to ensure its in a proper format to add/subtract dates. I.e. the date field in ur db might be a full datetime UTC field when it might be better to format it to yyyy-MM-dd first.