Problem adding calculated year to static month/day

Hi. If today’s date is after 7/15 (any year), I need to set an earliest date calculated field. In other words, if today is before 7/15/2004, the EarliestDate field should show 7/1/2003. If today is after 7/15/2004, the EarliestDate field show calculate to 7/1/2004.

The problem seems to be in adding the calculated year to the static month/day.

The field is a calculated date field. Here is my code:

REM {The following formula checks that the user cannot select};

REM {a date from the last fiscal year after 7/15 of this year};

tmpMo:=7;

tmpDy:=15;

tmpYr:=@If(@Today > ([7/15]) ; @Year(@Today);@Year(@Adjust(@Today;-1;0;0;0;0;0)));

tmpYr

This code is returning the correct year - but when I try to put together the month, day, and year, I get errors.

I tried

@Text(@Month([07/01])) + “/” + @Text(@Day([07/01])) + “/” + tmpYr

based on posts here, but it gave me “Incorrect data type for operator or @Function: Number expected.”

Any help is appreciated. Thanks!

Subject: @Text(@Month([07/01])) + “/” + @Text(@Day([07/01])) + “/” + @Text(tmpYr)

Subject: Had another problem with formula, but here is good solution

After changing my last line, the field calculated out to be “7/1/03/08/2005”. As I tried to get it corrected, I found a simpler way to get it. GOOD CODE IS BELOW:

REM {The following formula checks that the user cannot select};

REM {a date from the last fiscal year (7/1 to 6/30) after 7/15 of this year};

tmpYr:=@If(@Today > ([7/15]) ; @Year(@Today);@Year(@Adjust(@Today;-1;0;0;0;0;0)));

tmpDate:=“07/01/” + @Text(tmpYR);

@TextToTime(tmpDate)

Hope this helps anyone else working with the !#?## date/time fields!

Subject: RE: Had another problem with formula, but here is good solution

Your formula still has two problems.1. The date constant [7/15] is not valid. If it compiles at all, it will store the current year in the compiled formula. Next year the formula will fail. To fix this, you can replace it with:

@Date(@Year(@Today); 7; 15)

  1. tmpDate has a dependency on the user’s preferences, so it might fail for some users. To avoid this, you can replace the last two lines with:

@Date(tmpYR; 7; 1)

Subject: SOLUTION - and thanks

Boy, did I misunderstand @Date! Here is the working solution:

REM {The following formula checks that the user cannot select};

REM {a date from the last fiscal year (7/1 to 6/30) after 7/15 of this year};

tmpYr:=@If(@Today > @Date(@Year(@Today); 7; 15); @Year(@Today);@Year(@Adjust(@Today;-1;0;0;0;0;0)));

@Date(tmpYR; 7; 1)

P.S. It pays to go back and look at your old posts!

Subject: RE: @Text(@Month([07/01])) + “/” + @Text(@Day([07/01])) + “/” + @Text(tmpYr)

Thanks, Bill. I need to remember KISS!