Need to set a date field with a certain number of days

Hi All,

I need to set the DueDate field with a number of days.

doc.DateReceived has 13/01/2009

DueDate is the date I need to set from the number of days selected by a field “CalculationDaysToAdd”. I need to also keep in mind the Business days when I need to add for exemple 10 days to the DateReceived.

Dim DueDate As New NotesDateTime(doc.DateReceived(0) )

DaysToAdd = doc.CalculationDaysToAdd

.

Call DueDate.AdjustDay(DaysToAdd(0),True)

doc.DateReceived = DueDate ‘ I know this is wrong but at this time I get 12:00, 1200: as the DueDate

it is not working for me…

any help would be greate.

thanks

Alena

Subject: Need to set a date field with a certain number of days.

doc.DateReceived = DueDate ‘ I know this is wrong but at this time I get 12:00, 1200: as the DueDate

You’re overwriting the DateReceived field?

When is this code located? An certain event, or a button or something?

There is nothing wrong, IMO, about 12:00 as you probably didn’t specify a time, so the system defaults to that time.

Therefore if your date starts as 2009-01-13, that’s really 2009-01-13 Midnight.

Then if you determine the adjustday is 30 days. Then the new dateReceived will be

2009-02-12 12:00am (if I did my math right)

Subject: RE: Need to set a date field with a certain number of days.

Thanks for your comment…

The code is in the PostCalc event, I am setting the ReceivedDate then I add the NoDays then the code post calculates, I noticed in dubug that the ReceivedDate is not really set to the date I have just entered, how can I made the date physically there when I run the PostCalcul event? Right now the DueDate is still being set to nothing.

Dim DueDate As New NotesDateTime(doc.ReceivedDate(0) )

NoDays = doc.fldCalculationDays

Call DueDate.AdjustDay(NoDays(0),True)

TheDate = DueDate.DateOnly

Call uidoc.FieldSetText(“DueDate”,TheDate)

Subject: RE: Need to set a date field with a certain number of days.

Why aren’t you just using Formula Language and @Adjust in a computed field?

Subject: RE: Need to set a date field with a certain number of days.

well, I need to get the number from a profile document. I don’t have the number of days on the form itself.

thanks,

alena

Subject: * New issue–Need to set a date field with a certain number of days.

I had to change to @ functions, with script and holidays it gave me problems, I have this code running from an action button for my testing.

So NumDays field has 5 as the value, ReceivedDate has 10 nov 2008 for values, 2008-11-10,

FIELD NumDays := NumDays;

FIELD ReceivedDate :=ReceivedDate;

Today := fldReceivedDate;

@For( x := 1;

@BusinessDays( Today ; @Adjust(Today;0;0;x;0;0;0) ; 1:7) <= NumDaysToAddNum;

x := x +1; num := x);

test := @Adjust(Today;0;0;num;0;0;0); ’ test is = to the rithg date.

** if the code stops here then it is ok as the @for funciton gives me the right values being 2008-11-17, it does skip the weekend. The problem is now that I have to skip the Holidays, in the field StatHolidays there are all 10 holidays for the year. But the code I used give me the day on a weekend, so I am going something wrong…

info :=@BusinessDays( fldReceivedDate ; test ; 1:7 ; @TextToTime(StatHolidays) );

@Prompt([Ok];“”;@Text(info)) ’ wrong value here…???

alena

Subject: RE: Need to set a date field with a certain number of days.

Based on your description it sounds like you’re possibly gettting the data from a backend document when you want the value in the front end. Therefore you will need to pull it from the UI.

Therefore does duedate look better in the debugger when you do this:

Dim DueDate As New NotesDateTime( uidoc.FieldGetText(“ReceivedDate”) )

Subject: RE: Need to set a date field with a certain number of days.

Thanks Stephen it is working greate…

Subject: * New issue–Need to set a date field with a certain number of days.

Too bad StatHolidays is not a multivalue Date/Time - wonder if this will cause trouble.

I also started you loop at Numdays + NoWks * 2, as it seems kinda pointless to start at 1 when you know you need to jump at least the number of days you requested. The NoWks count means we know we can skip at least 2 more days for each weekend.

Today := fldReceivedDate;

NoWks := @Integer( NumDay/5 ); REM { MADE A CORRECTION HERE };

@For( x := NumDays + (NoWks *2);

@BusinessDays(Today; @Adjust(Today;0;0;x;0;0;0); 1:7; @TextToTime(StatHolidays) ) <= NumDays;

x := x +1; 

num := x);

test := @Adjust(Today;0;0;num;0;0;0);

Subject: RE: * New issue–Need to set a date field with a certain number of days.

working greate Stephane, thanks so much!Alena