Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My First Formula 1

Status
Not open for further replies.

benlinkknilneb

Programmer
May 16, 2002
590
US
Hi all,

I'm doing some maintenance on a Notes database, and I have no experience with the system. I've gotten almost everything figured out for this assignment except for one thing:

I have a formula that should return a Part Number concatenated with a date code (don't ask why... I'm dealing with a very ugly database here) like so:

102381990013

Which is read as follows:

Part 10238199 run on Julian date 001 (Jan 1) 2003.

I can access the Part Number as a string and the date as a standard date.

Here's my formula so far (doesn't work):
TBPARTNUM+(TBDATE - @Date(@Year(TBDATE);1;1))+@right(@Year(TBDATE);1)

Can anyone help me out?

TIA
Ben
 
Maybe something like this ...

list := 0:31:28:31:30:31:30:31:31:30:31:30 ;
priorMonths := @Subset( list ; @Month(TBDATE) ) ;
julianDay := @Sum( priorMonths : @Day(TBDATE) ) ;
yearDigit := @Right( @Text(@Year(TBDATE)) ; 1 ) ;
partDate := @Text(TBPARTNUM) + @Text(julianDay) + yearDigit ;
partDate

Dale

Find me @ onlinecorporatesoftware.com
 
Actually the julian day should be zero filled according to your spec.

partDate := @Text(TBPARTNUM) + @Right("000"+@Text(julianDay);3) + yearDigit ;

and if TBPARTNUM is numeric then you might require the same sort of processing for it too.

Cheers


Find me @ onlinecorporatesoftware.com
 
Thanks so much for your help, Dale,

I have just one more question. I've been trying to add a leap year calculation to the field:

tmpyr:=@year(TBDATE);
If @modulo(tmpyr;4)=0 Then
If @modulo(tmpyr;100) != 0 or @modulo(tmpyr;400) = 0 Then
list := 0:31:29:31:30:31:30:31:31:30:31:30 ;
else
list := 0:31:28:31:30:31:30:31:31:30:31:30 ;
End if
else
list := 0:31:28:31:30:31:30:31:31:30:31:30 ;
End if

I can't get these comparisons to work. I got the syntax from Domino Designer help; it says something about an operator or " expected at the = sign in the first "if" statement. Can you set me straight?

Ben
 
Never mind; I got it! I was using the LotusScript "If" in a formula... once I straightened that out, it works fine. Thanks again for your help, Dale.

Ben
 
In this case (the leap year code) check for what happens when @modulo(tmpyr;100) is not equal to zero and what happens when it is. I think you will find that or is not a valid formula statement. To perform a logical OR in formula use the | vertical bar. I still occasionally (usually late at night) confuse the LotusScript use of "+" and "&" with the formula usage and I've been doing both for a longggg time.

Find me @ onlinecorporatesoftware.com
 
Absolutely correct, Dale,

I had a little trouble with the "or"; but I eventually got the "|". Here is the solution that I am using:
Code:
tmpyr:=@Year(TBDATE);

 list:=@If ((@Modulo(tmpyr ;4)=0) & (@Modulo(tmpyr;100) != 0 | @Modulo(tmpyr;400) = 0) ; 0:31:29:31:30:31:30:31:31:30:31:30 ; 0:31:28:31:30:31:30:31:31:30:31:30);

priorMonths := @Subset( list ; @Month(TBDATE) ) ;
julianDay := @Sum( priorMonths : @Day(TBDATE) ) ;
yearDigit := @Right( @Text(@Year(TBDATE)) ; 1 ) ;
partDate := @Text(TBPARTNUM) + @Right("000"+@Text(julianDay);3) + yearDigit ;
partDate
The algorithm I used for leap years was found on a website somewhere; I Googled for "Leap Year Algorithm".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top