das_k_tushar
6th September 2004, 15:16
What is the syntax for converting date to week of the month.

like - 06/09/2004 - 1stweek,sept,2004

Best Regards,

mr_suleyman
6th September 2004, 17:49
hello there
you can use num.to.week() functions to get week value by writing your method.

good lucks

das_k_tushar
7th September 2004, 07:25
num.to.week() converts no of day number in week ,week number in year like that.

I am looking for an function which convert BaaN Date into week of the month,year.

Thanks.

mr_suleyman
7th September 2004, 07:47
I don't think that there is a function for that . You must create your functions by using num.to.week().

Good lucks...

rameshr
7th September 2004, 08:54
long dd,mm,yy

num.to.date(date_field,yy,mm,dd)
date_string = sprintf$(str$((dd-1/7)+1) & "st week , %D(20H %04Y)",date_field)

SandraDiehl
1st June 2020, 20:04
I'm in need to do this same type of logic to set up payment terms for our customer who wants to be paid the 2nd and 4th Wednesday of the month. Did anybody come up with a solution. I'm not so sure about this suggestion when just looking at it I don't see how it would determine if it's the 2nd or the 4th Wednesday of the month.

num.to.date(date_field,yy,mm,dd)
date_string = sprintf$(str$((dd-1/7)+1) & "st week , %D(20H %04Y)",date_field)

I have logic that gives me the Wednesday but to determine the nth occurrence seems to be tricky.

mark_h
2nd June 2020, 15:17
What I would probably do is get which day of the week is the first day of the month. If Monday then I know the first Wednesday is +2, if it is Tuesday then first Wednesday is +1, if Wednesday then +0, if Thursday then +6, Friday +5, Saturday +4, Sunday +3. So now you have the date of the first Wednesday of the month. The billing dates would be first Wednesday +7 and second billing would be +21. So if you were in month june the first day of the week is Monday for 6/1/2020, first Wednesday 6/1 +2 or 6/3/2020, then the billing dates would be 6/10/2020 and the 4th occurrence(second billing date) would be 6/3/2020 + 21 or 6/24/2020. Then you could test the current billing date against the first Wednesday +7 or +21. Kind of like:

if current_billing_date = first_wednesday+7 or current_billing_date = first_wednesday+21) then
bill_this_customer()
endif

SandraDiehl
3rd June 2020, 13:40
Thanks Mark, after some thinking and working with a buddy we came up with this which is going into testing right now...I have a custom table tcmcs998 that is called through tcmcs0113m000, the new table holds the day of the week and occurrence they that payment type will use. In this function it receives the "potential" due day that was pre-calculated based on other rules. Now the logic looks to see if that date falls on the "payment request day" and then checks to see if it's one of the occurrences.

function domain tcdate set.duedate.to.selected.weekday(domain tcdate in.dued)
{
long i
long s.dayno,y.dayno
domain tcweek s.week
domain tcdynm curr.dayn
domain tcdynm next.dayn
domain tcyrno s.year
domain tcdate o.date
long ret,mm,dd,yyyy
long exit.loop.flag, xdd

exit.loop.flag = 0
num.to.week(in.dued,s.dayno,y.dayno,s.week,s.year)
curr.dayn = itihra0001.convert.daynumber.to.dayname(s.dayno)
o.date = in.dued
while exit.loop.flag = 0
num.to.week(o.date,s.dayno,y.dayno,s.week,s.year)
next.dayn = itihra0001.convert.daynumber.to.dayname(s.dayno)
if next.dayn = wkdy then
| which occurrence is this date
ret = num.to.date(o.date,yyyy,mm,dd)
xdd = round((dd / 7) + 1.0, 0, 2)

if tcmcs998.first = tgyenox.yes and xdd = 1 or
tcmcs998.second = tgyenox.yes and xdd = 2 or
tcmcs998.third = tgyenox.yes and xdd = 3 or
tcmcs998.forth = tgyenox.yes and xdd = 4 then
|YES!!
exit.loop.flag = 1
endif


endif
if not exit.loop.flag then
o.date = o.date + 1
endif
endwhile

return(o.date)

}