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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to manipulate table FIELDNAME? 4

Status
Not open for further replies.

Rock4J

Programmer
Jan 14, 2013
94
MY
Hi,

I have a table that looks like this:

Tablename: Dchkroll.dbf
Fieldname -> Name , Empno , D01, D02, D03, D04, D05, D06, ... , D29, D31
(D01 to D31 is referring to working days which holding working-hours for the day.)

I want to manipulate the D01-D31 (1 to 31 without the 'D') from the above table to compare it with 'HOLDATE' (DAY) value in the following table:

Tablename: Holiday.dbf
Fieldname -> Month , Holdate , Holdesp , PH
('HOLDATE' values is in DATE format)

The code that i'm trying to write is something like this:

[using do-while/for-next/scan-endscan to read from Dchkroll.dbf]
if the 1-31 of the D01-D31 fieldname is equal to day(HOLDATE) then
*store data into a cursor cursor_table_name (name, empno, holdate, hours)
end if

I'm actually trying to create a report to list out employees who have worked on holiday.

Probably there is other way to write this code that would be much better.

Hopefully my explanation is clear. Please help. :)

Thanks.

Regards,
Rocky
 
Thanks so much mm0000 !! yeah.. it is working already!! :D Thanks too dbMark.. :)

Here is the code that i'm using which is working (vfp6):
Code:
CREATE CURSOR repcursor (name c(30),empno c(10),holdate d,hours n(2))
	
SELECT 0
USE J:\Apps\Chkroll\Data\Holiday.dbf IN SELECT ("Holiday")

SELECT 0
USE J:\Apps\Chkroll\Data\Dchkroll.dbf IN SELECT ("Dchkroll")

LOCATE

SCAN
FOR icount = 1 TO 5
	mcdate = 'D'+PADL(icount,2,'0')
	STORE &mcdate TO m.nhours
	STORE icount TO m.icount
	STORE name TO m.cname
	STORE empno TO m.cempno
	SELECT holiday
	SCAN
	IF m.nhours # 0
		IF m.icount = DAY(holdate)
			STORE holdate TO m.dholdate
			SELECT repcursor
			APPEND BLANK
			replace name WITH m.cname
			replace empno WITH m.cempno
			replace holdate WITH m.dholdate
			replace hours WITH m.nhours
		ENDIF
	ENDIF  
	SELECT holiday 
	ENDSCAN
	SELECT dchkroll
ENDFOR  
ENDSCAN

THANKS TO ALL OF YOU !! :)

Regards,
Rocky
 
Correction:

FOR icount = 1 TO 31 *5

lols

Regards,
Rocky
 
m00000, just one thing:
I wonder why you do STORE icount TO m.icount, icount is no field of a table, it's the FOR loop counter variable in the first place.

Seeing how few records Rocky showed us for holiday.dbf I would still turn the code around to scan holiday.dbf and find the corresponding d-field of Dchkroll records for the corresponding month.

Bye, Olaf.
 
Olaf,

Yes, there is not need to store the icount value to m.icount. The code was written 'on the fly' so there could be some redundant lines in my code.

There is no date/month information in the Dchkroll table given by Rocky to be able to match dchkroll data with holiday data.

MM

 
>There is no date/month information in the Dchkroll table given by Rocky to be able to match dchkroll data with holiday data.

Well, anyway you do so the other way around, you test for day number matching, so you assume the month/year part is corresponding. Rocky has to know what record of dchkrll he compares to which holiday records, or data of every months 25th would count for christmas for example. That info may be the folder location or whatever else, or dchkroll only has info about the current month anyway, each record for a different employee. Rocky knows best.

But matching a holidate with a day only is of course a match not necessarily right. That's also a reason, no matter if you stay with this way around or turn it the other way, you have to know if D-Fields contain data about the month/year of holidate.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top