INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression - "On This Day..."  (Read 1304 times)

DaveMan538

  • Recent member
  • *
  • Posts: 26
  • So much good music. So little time...
Expression - "On This Day..."
« on: December 07, 2012, 10:24:10 pm »

I've been working on tagging music with the complete date (mm/dd/yyyy instead of just yyyy) and I'd like to create a View that consists of songs that have a date of <today> from any year.  I found enough info in the wiki to create custom fields for <today's day> and <current month> but I have not been able to build an expression that will allow me to pull the items that match today's Day and Month.

Any help would be appreciated.  Thanks!   ;D
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression - "On This Day..."
« Reply #1 on: December 07, 2012, 11:29:07 pm »

Here's one way:

ifelse(
   !Regex([Date], /#^(\d+)/(\d+)/(\d+)#/),
      Year-only date,
   Compare([R2], =, formatdate(now(), d)),
      Matched [R2],
  1,
      No match
)

This matches against a full date in the format of mm/dd/yyyy, and grabs the day portion.  if there is not a full date, Year-only date is output.  With the day portion inside [R2], it is compared against the day portion of Now(), and the match is output; otherwise, No match is output.

To use as a custom rule in a smartlist or file rules area:

   [=Compare(Regex([Date], /#^(\d+)/(\d+)/(\d+)#/, 2), =, formatdate(now(), d))]=1
Logged
The opinions I express represent my own folly.

DaveMan538

  • Recent member
  • *
  • Posts: 26
  • So much good music. So little time...
Re: Expression - "On This Day..."
« Reply #2 on: December 08, 2012, 09:52:29 am »

Thanks so much, MrC!!!   ;D ;D ;D

It does work for the day only.  That's cool because this returns more results.  Is there a way to add the Month comparison to that?  So that it would return all songs from "December 9th" as opposed to the 9th of any month?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression - "On This Day..."
« Reply #3 on: December 08, 2012, 11:30:37 am »

Sure, here you go:

ifelse(
   !Regex([Date], /#^(\d+)/(\d+)/(\d+)#/),
      Year-only date,
   isequal([R1]:[R2], formatdate(now(), M:d)),
      Matched [R1]:[R2],
  1,
      No match
)

or as a query (for Set rules for file display):

  [=isequal(Regex([Date], /#^(\d+)/(\d+)/(\d+)#/, 1):[R2], formatdate(now(), M:d))]=1
Logged
The opinions I express represent my own folly.

DaveMan538

  • Recent member
  • *
  • Posts: 26
  • So much good music. So little time...
Re: Expression - "On This Day..."
« Reply #4 on: December 08, 2012, 01:17:39 pm »

MrC, you sir, are a man among men.  That's just cool as dirt!  Thanks again! 

The other cool thing, is being able to run the same expression against any media type.  Great for home movies and photos as well!! 
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression - "On This Day..."
« Reply #5 on: December 08, 2012, 01:39:12 pm »

MrC, you sir, are a man among men.

My wife says "But that's ten itty-bitty men", so I'll take what I can get.
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up