Birthday query for a property

Below I finally managed to finish a Birthday query. Maybe someone will find it useful. I have it in my default-queries and it shows a birthday if the property “birthday:: [[2000/01/31]]” is filled with today’s day.

If someone can make it easier, shorter, more readable please let me know :slight_smile:

{:title "🎂 Birthday"
  :query [:find (pull ?b [*])
    :in $ ?today
    :where
       [?b :block/properties-text-values ?props]
       [(get ?props :birthday) ?birthday]
       
       [(str ?birthday) ?birthdayString]
       [(subs ?birthdayString 7 9) ?month]
       [(subs ?birthdayString 10 12) ?day]

       [(str ?today) ?td]
       [(subs ?td 4 6) ?todayMonth]
       [(subs ?td 6 8) ?todayDay]

       [(= ?month ?todayMonth)]
       [(= ?day ?todayDay)]
       
]
:inputs [:today]
:collapsed? false}

Well done! I would say this works just fine, unless you want to get into regex I suppose.

1 Like