Re: Date Script
Hi Everyone,
Please, see below code and point out what was wrong.
I'd like to save my result into table with start date.
I also have the several problems with this scripts.
(1) more than 7 days duration case. If the duration is more than a week period, I think, I have to create new record and save new Workoder_id, week number and dates. How can I do this?
(2) Calculate it with Add_bus_days() and allowance for weekend days. I simply tried as "add_bus_days(vSdate-1+1) but Error message.
(3) If I changed the existing records then How to revise the current records
Hi Everyone,
Please, see below code and point out what was wrong.
I'd like to save my result into table with start date.
I also have the several problems with this scripts.
(1) more than 7 days duration case. If the duration is more than a week period, I think, I have to create new record and save new Workoder_id, week number and dates. How can I do this?
(2) Calculate it with Add_bus_days() and allowance for weekend days. I simply tried as "add_bus_days(vSdate-1+1) but Error message.
(3) If I changed the existing records then How to revise the current records
Code:
dim thdr as p dim i as n dim vDur as n dim vSDate as d dim vNext as c dim vDate as d dim tSch as p dim vSun as d dim vMon as d dim vtue as d dim vWed as d dim vThu as d dim vFri as d dim vSat as d tSch=table.open("wrkodr_schedule") thdr=table.open("wrkodr_hd",file_rw_shared) thdr.index_primary_put("Wrkodr_Id") thdr.fetch_first() while .not. thdr.fetch_eof() vSDate=thdr.Plan_startdate vDur=thdr.Plan_duration vWrkOdr=thdr.Wrkodr_id if vdur>0 then for i =1 to vdur 'vsdate-1+i vnext= vSdate-1+i 'How to get the business days(add_bus_days) with option, Allow or not on weekend. vDate= ctod(vNext) 'Convert to Date vWeek= week(vDate) 'Convert to Week Number 'If vDate = "Sunday" and Week(vNext)= Week(?) then store it to vSun for tempoary 'cdow(ctod(vNext))="Monday" select case dow(vdate)=1 'If vdate ="sunday(1)" then save to vSun vSun= vDate case dow(vdate)=2 vMon=vDate case dow(vdate)=3 vTue=vDate case dow(vdate)=4 vWed=vDate case dow(vdate)=5 vThu=vDate case dow(vdate)=6 vFri=vDate case dow(vdate)=7 vSat=vDate end select next i else ui_msg_box("No Duration","Enter Duration Information") end Next end if tSch=table.open("wrkodr_schedule") tSch.enter_begin() tSch.Wrkodr_id=vWrkOdr tSch.Week_number=vWeek tSch.Sun=vSun tSch.Mon=vMon tSch.Tue=vTue tSch.Wed=vWed tSch.Thu=vThu tSch.Fri=vFri tSch.Sat=vSat tSch.enter_end(.t.) thdr.fetch_next() end while thdr.close() tSch.close() end
Comment