1 2 Previous Next 18 Replies Latest reply on Mar 27, 2014 11:31 AM by erolst

omit year from Birthday calculation

I think this will be an easy fix, but I can't think of the right function to use!

I am having a Birthday alarm (alarming upcoming Birthdays). Using a calculation field. My only problem is that I would like to omit the year of the calculations of Birthday and Currentdate. So the alarm reacures every year. And not only in the actual year of birth (Who would need to be reminded of a Birthday that actually happend today )

I was thinking using maybe Left(Get(CurrentDate);5) -> guessing this would return 03/25 But I am unsure about this.

• 1. Re: omit year from Birthday calculation

You can pull the month and day of month out of dates for comparison using the month and day functions:

• month(yourdate)
• day(yourdate)

Just compare the results of doing this on the birthday date to doing the same on the date to be checked (the current date?).

1 of 1 people found this helpful
• 2. Re: omit year from Birthday calculation

And if you make the comparison in a non leap-year, don't forget people born on the 29th February …

• 3. Re: omit year from Birthday calculation

The only problem with that is in cases where the birthday is in the beginning of the month.

Here is my Calc:

Let([

bdm=Month(Birthday);

bdd=Day(Birthday);

tdm=Month(Get(CurrentDate));

tdd=Day(Get(CurrentDate))

];

Case (

bdm=tdm and bdd > tdd and bdd <tdd+4; "Upcoming";

bdm=tdm and bdd=tdd; "Today";

bdm=tdm and bdd<tdd and bdd > tdd-4 ; "Recent";

""))

So lets say today is the 03.30. and the birthday is on 04.01. it should alarm, but it doens't because the month is not the same!

• 4. Re: omit year from Birthday calculation

Hmm... good point... But if I take the year out of the comparison would that not solve the problem anyways?

• 5. Re: omit year from Birthday calculation

Try this one; if you also want to look back, you need to tweak it a bit …

Let ( [

~b = Date (4 ; 1 ; 1983 ) ;

~d = Date ( 3 ; 25 ; 2014 ) ;

offset = 7 ;

inFinalDays = Month ( ~d ) = 12 and Day ( ~d ) > 31 - offset ;

target = Date ( Month ( ~b ) ; Day ( ~b ) ; Year ( ~d ) + inFinalDays )

] ;

Case (

target = d ; "Today!" ;

target > d and target <= d + offset ; "Upcoming within " & offset & case ( offset = 1 ; " day." ; " days." )

)

)

• 6. Re: omit year from Birthday calculation

Ok, I can see that this is working but I can't fully comprehent why...

It looks like Target creates a new "current date" that is giving the range.

inFinalDays = Month ( ~d ) = 12 and Day ( ~d ) > 31 - offset ;

target = Date ( Month ( ~b ) ; Day ( ~b ) ; Year ( ~d ) + inFinalDays )

Why do you write Month(date) = 12 ?

and same why Day(date) > 31 ?

Also

target > d and target <= d + offset ; "Upcoming within " & offset & case ( offset = 1 ; " day." ; " days." )

this looks like offset will be variable depending on how close the day is approaching, like a countdown... however in the definition its just offset = 7,

therefore there will be no countdown right?

Sorry, I just want to learn as I do this and understand rather then copying being happy that it works.

Especially since I wanna build in the whole look back option, it would be better to understand

Thanks

• 7. Re: omit year from Birthday calculation

offset = Case ( Day (~b) - Day (d) > 0 and Day (~b) - Day (d) < 8; Day (~b) - Day (d); "")

I think this would fix the second point...

But I still have no understanding of the first point

• 8. Re: omit year from Birthday calculation

All you need is to substitute the year of birth and compare the date with the current year.

Since you should be alarmed prior to the event you can even calculate the number of days till the event.

Let ( [

dob = date ( 4 ; 3 ; 1950 ) ;                    // test date of birth

curr = Get ( CurrentDate ) ;

thisdate = date ( month ( dob ) ; day ( dob ) ; year ( curr ) ) ;

daysToGo = date ( month ( dob ) ; day ( dob ) ; year ( curr )

+ ( curr > thisDate ) ) - curr          // add one year when dob has passed

] ;

if ( daysToGo < 8 ; daysToGo )                    // 8 is the alarm period ( 7 days in advance)

)

Leap years are taken care automatically.

-Winfried

1 of 1 people found this helpful
• 9. Re: omit year from Birthday calculation

raphthepenguin wrote:

Especially since I wanna build in the whole look back option

Try this one:

Let ( [

offset = 30 ;

~dob = Date ( 1 ; 15 ; 1983 ) ;

~cd = Date ( 12 ; 28 ; 2014 ) ; // checkDate

~mb = Month ( ~dob ) ;

~db = Day ( ~dob ) ;

~md = Month ( ~cd ) ;

~yd = Year ( ~cd ) ;

~this = Date ( ~mb ; ~db ; ~yd ) ;

targetAhead = Date ( ~mb ; ~db ; ~yd + ( ~this < ~cd ) ) ;

targetBack = Date ( ~mb ; ~db ; ~yd - ( DayOfYear ( ~cd ) < offset ) )

] ;

Case (

targetAhead = ~cd ; "Today!" ;

targetAhead > ~cd and targetAhead <= ~cd + offset ; "Upcoming: in " &

Let ( [ ~u = targetAhead - ~cd ; ~s = Case ( ~u = 1 ; " day." ; " days." ) ] ; ~u & ~s ) ;

targetBack < ~cd and targetBack >= ~cd - offset ; "Recent as of " &

Let ( [ ~r = ~cd - targetBack ; ~s = Case ( ~r = 1 ; " day ago." ; " days ago." ) ] ; ~r & ~s )

)

)

• 10. Re: omit year from Birthday calculation

For some reason, this one works. However the looking back does not work with 30 days. But if I set it lower it works. And since I don't want to look a whole moth back (only like 3 days) thats totally fine.

But is there a logical reason for that? I again just want to understand

Also can you explain to me why you wrote in your previous solution following:

Why do you write Month(date) = 12 ?

and same why Day(date) > 31 ?

Again, just so I understand!

Thanks so much for your help!

• 11. Re: omit year from Birthday calculation

raphthepenguin wrote:

For some reason, this one works. However the looking back does not work with 30 days.

What result do you get for:

~dob = Date ( 11 ; 11 ; 1983 )

~cd = Date ( 1 ; 2 ; 2014 )

? I get "52 days ago" …

raphthepenguin wrote:

Again, just so I understand!

You need to handle the edge case that you're within the first offset days of the year; then the year of the virtual target date needs to be shifted back.

By the same token, my check was for looking forward from the final days, but the check I saw in Winfried's post is better …

Go through the calculation and try to understand what the individual variables do – which you can tell from the way they're subsequently used.

• 12. Re: omit year from Birthday calculation

Thats what I did (going through the function) and that was the last unclearity! But it does make sense.

As a result for your dates (in the DataViewer) I get no result

• 13. Re: omit year from Birthday calculation

raphthepenguin wrote:

As a result for your dates (in the DataViewer) I get no result

That's odd …

• 14. Re: omit year from Birthday calculation

Ah, in that one you set the offset to 60...

then it works,

But those days don't work:

~dob = Date ( 1 ; 15 ; 1983 ) ;

~cd = Date ( 1; 20 ; 2014 )

Its weird!

1 2 Previous Next