bkkland
1st February 2006, 20:13
how to write a script to calculate the field "plan delivery date" based on the order date excluding weekend??? I don't know where to start... :(
I have the order date on my text file with a bunch of other information for importing sales order.
the delivery date = order date + 3 excluding weekend
Please advise...Thank you!!!
Regards,
mark_h
1st February 2006, 20:56
If all you have to do is add three to an order then just check the order date to see if it is wed, thurs or friday. If so then just add +5 instead of +3, basically adding 2 days to skip the weekend.
shah_bs
1st February 2006, 21:52
Another option is to use the Company Calendar.
bkkland
1st February 2006, 23:12
can you be more specific on how to check the day? I'll try to write some script and post it later so please advise.
The order date format is mmddyy.
What is this code mean?
long tdate
tdate = format.to.date(default.datef, int(date))
We never use the Company Calendar so I'm not sure it'll be still an option in this case.
Thank you,
beginer
2nd February 2006, 06:24
Maintain a Customised Date Format or use a existing date format which gives the Day Name.
Then using this date format (eg. %D0xx) & function num.to.week(.........) which will give u the Day No. ( this depends on what is defined as first day of week.....Mostly its defined as Sunday)
So , accordingly u can find if yr del. date falls on weekend & can adjust.
en@frrom
2nd February 2006, 10:51
It of course is neater to use the calendar, because you will be using less hard-coded scripting, and more standard-Baan fundtionality. It is not so complicated to set it up; but do think carefully before setting it up; because it can have implications for the future...
mark_h
2nd February 2006, 16:30
Check out sprintf structure:
some.day = val(sprintf$("%D(%e)",some.date))
This will return the day of the week(1 to 7). Never really used this so I am not sure which day is which. If I was doing this I would use en's method and use the company calendar.
lbencic
2nd February 2006, 22:50
FYI, as mentioned the day of week that gets returned through the date functions needs to be adjusted for the Baan setting for 'First Day of the Week'.
If you can get the source for the Baan include tihra0001 (they should give this freely if you are in good standing), then the call I use to convert a date to day name is:
my.dayname = itihra0001.convert.date.to.dayname(date.num())
bkkland
3rd February 2006, 00:20
I'm sorry...I still don't get it...
how to use those functions. I looked up some information but it's so confusing. I found some threads but not much detail
how these work, how to use these:
* num.to.week
* date.to.num
In case, the date(recieve date- prdt) on my text file is 022106...Do I have to convert it to anything?
When the file is imported using exchange schme, I'm trying to add a condition to caculate the delivery date(tdsls040.ddat)
- Delivery date = recieved date - 3 days(ecluding weekend)
- EX. if the recieved date is on Tuesday(022106), the delivery date should be Thursday(021606)
Parameter by condition
1. prdt numeric
2. ddat numeric
long prdt1
long
prdt1 = date.to.num(prdt)
| do I need to convert it??
|I think what on my file "prdt" is numeric - double bec.
|I got error message saying illegal type, double should be long...
prdt2 = num.to.weeK(prdt1)
| not sure what to do....
sorry, if it looks so horrible...but I'm trying... :(
Please advise...
THANK YOU & THANK YOU
csecgn
3rd February 2006, 12:43
Take a look in the help at sprintf$. I've copied just the for you interesting part:
string sprintf$( string format(.) [, expression, ...] )
%D(format) Use for dates.
...
%e day in week 1 - 7
...
result = sprintf$("%D(%e))", <date to check>)
The result is a string. Depending from the first day of week in your company, you can check if the result day is saturday or sunday.
Just add the needed days to the next monday.
hth
Regards
csecgn
mark_h
3rd February 2006, 16:31
A little routine I use to convert a date - of course my year is 4 characters:
num.day = val(read.date(4;2))
num.month = val(read.date(1;2))
num.year = val(read.date(7;4))
adj.date = date.to.num(num.year, num.month, num.day)
You may just have to add 2000 to your year. Of course since I am not familiar with your data it may take some coding to determine what to add. Now you have a date to start checking the company calendar. Or you can use the sprintf line this somedate=("%D(%e)",adj.date).
bkkland
9th February 2006, 00:28
how to use function date.to.num with the date that data type is double?
In my ASCII file, the prdt = 031506. The default date format specified at Exchange is "mmddyy"
With the coding, I would expect the result of ddat to be "03-10-2006", but I got "04-02-0087"
parameter
* ddat
* prdt
long day
long neg
neg = 3
ddat = prdt - neg
day = (ddat/7)
if day = 7 then
ddat = ddat - 2
endif
if day = 1 then
ddat = ddat - 2
endif
return(ddat)
Please help!!! I try to use the "date.to.num" function to convert the "prdt", but it said...expect 3 agruments, type mismatch "double" should be "long"
I try to use the sprintf$...replacing "ddat = prdt - neg" with
ddat = date.num.to(lval((sprintf$("%D(Date: %02d,%02m,%02Y)", prdt))) - neg
but got error message....ddat not expect. By default, data type of "prdt" and "ddat" are double, but the fucntion "date.to.num" expect data type "long"....how to make it the same....
Please advise.....THANK YOU!!!!!!!!!!!!!! :(
Regards,
mark_h
9th February 2006, 16:45
You should have mentioned early on that you were using exchange. I thought you were reading a file in a normal program.
Create condition script - with the date parameter you want to use. The condition script should have type of "Date". The condition parameter should have type numeric.
You condition script will look something like this:
domain tcdate somedate
somedate = format.to.date(default.datef,int(dldt)) | dldt is my parameter
message(sprintf$("%D(Date: %02d,%02m,%02Y)", somedate))
return(somedate)
At this point somedate is in the correct format. At least on ours it works that way. Once you have somedate you can do the other calculations. You may want to just play with it by loading a few records.
bkkland
10th February 2006, 19:30
Thanks All For Your Help!!!!