Paradox Community

Items in pnews.paradox-programming

Subject:Re: Help with my code please example below
Date:13 Oct 2021 17:07:28 -0400
From:"Tony Spencer" <tracy.fairbrother@btopenworld.com>
Newsgroups:pnews.paradox-programming



 I have a database called dogsdb. With 4 years of data in iy.

I want to put a start date in example 01/01/2019. I then want to get two
weeks of data then do some work on it. Store the results The move on and
get another two weeks of data until I have exhausted all the data. 
So 01/01/2019 until 15/01/2019. Then do the work store results loop the data
and then move the dates on 16/01/2019 until 31/01/2019. Then carry on until
all the data is done.

Hope this helps  





































Peter <peterspammenot@whiteknight.email> wrote:
>Are you getting an error or is it that you are not getting the results 
>you want?
>
>Peter
>
>On 10/12/2021 11:03 p.m., Tony wrote:
>> Can someone help me with the code below please. I want to put a start
date
>> in and move the code date forward to capture the next set of data. Example
>>   So start 01/07/2019 until 15/07/2019. Do the analysis add to the stats2
>> table then move on 16/07/2019 until 31/07/2019 do the same add results
to
>> stas2 table. I want this to carry on until the end of my data which is
12/10/2021.
>> Not sure what im doing wrong .
>> 
>> 
>> 
>> proc StartDate(d date) date
>> ; proc returns start date for given date
>> ; if date is before 16th, start date is begining of month
>> 	if day(d) < 16 then
>> 		return( date(month(d),1,year(d)) )
>>      else
>> 		return( date(month(d),16,year(d)) )
>>      endIf
>> endProc
>> 
>> proc EndDate(d date) date
>> ; proc returns end date for given date
>> ; if date is before 16th, end date is 15,
>> ; if date if 16th or later, end date is end of month
>> 	if day(d) < 16 then
>> 		return( date(month(d),15,year(d)) )
>>      else
>> 		return( date(month(d),daysInMonth(d),year(d)) )
>>      endIf
>> endProc
>> 
>> 
>> method run(var eventInfo Event)
>> var qb query
>> 	 TC TCursor
>> 	 dStart, dEnd Date
>> 	 mStart, mEnd Date
>> 	 sDate String
>> 	 mDate String
>> 		 tab table
>>   
>> 
>> 	 endVar
>> 
>> 
>> 	dStart = date(7,01,2018)
>> 	mStart = date(7,16,2018)
>>     ; and now start looping
>>     while dStart < today()
>> 		dStart = StartDate(dStart)
>> 		dEnd   = EndDate(dStart)
>> 		mStart = StartDate(mStart)
>> 		mEnd   = EndDate(mStart)
>> 		; create a condition for date      ex: ">=1.1.2018 , <=15.1.2018"
>>        sDate = ">=01/07/2018,<="+string(dEnd)
>>        ; and now do something with this string
>>        ; put here your querys and do smething with them
>> 
>> 			mDate = ">="+string(mStart) + ", <="+string(mEnd)
>> 
>> 
>> 
>>     qb= Query
>> ANSWER: :PRIV:ANSWER.DB
>> 
>> OPTIONS: NO AUXILIARY TABLES
>> Stats1.DB | Race name |
>> Delete    | not blank |
>> 
>> EndQuery
>> 
>> 		qb.executeQBE()
>> 	  qb= Query
>> ANSWER: :WORK:Stats1.DB
>> 
>> Stats1.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
|
>> 
>>            | Check     | Check    | Check   | Check  | Check  | Check
   |
>> 
>> 
>> Stats1.DB | Race type | TfGoing | Going  | Pos    | Btn    | Trap   |
Name
>>    |
>>            | Check     | Check   | Check  | Check  | Check  | Check  |
Check
>>   |
>> 
>> Stats1.DB | Age    | Sex    | Bend.1 | Bend.2 | Bend.3 | Bend.4 | Comments
>> |
>>            | Check  | Check  | Check  | Check  | Check  | Check  | Check
>>    |
>> 
>> Stats1.DB | ISP    | TFR    | Official time | Break time | Trainer | Betfair
>> |
>>            | Check  | Check  | Check         | Check      | Check   |
Check
>>    |
>> 
>> Stats1.DB | Race name_1 | Racetime_1 | Race No_1 | Date_1 | Grade_1 |
>>            | Check       | Check      | Check     | Check  | Check   |
>> 
>> Stats1.DB | Distance_1 | Race type_1 | TfGoing_1 | Going_1 | Pos_1  |
Btn_1
>>   |
>>            | Check      | Check       | Check     | Check   | Check  |
Check
>>   |
>> 
>> Stats1.DB | Trap_1 | Name_1 | Age_1  | Sex_1  | Bend.1_1 | Bend.2_1 |
>>            | Check  | Check  | Check  | Check  | Check    | Check    |
>> 
>> Stats1.DB | Bend.3_1 | Bend.4_1 | Comments_1 | ISP_1  | TFR_1  |
>>            | Check    | Check    | Check      | Check  | Check  |
>> 
>> Stats1.DB | Official time_1 | Break time_1 | Trainer_1 | Betfair_1 | RaceN
>>   |
>>            | Check           | Check        | Check     | Check     |
Check
>>   |
>> 
>> EndQuery
>> 
>> 		qb.executeQBE()
>> 
>>   qb=Query
>> ANSWER: :WORK:Races.DB
>> 
>> DogsDB.DB | Race name             | Racetime | Race No | Date
>>     | Grade  |
>> 			 | Check _join3, Crayford | Check    | Check   | Check _a,~mDate  
| Check
>>   |
>> 			 | Check _join3          | Check    | Check   | Check <_a         
| Check
>>   |
>> 
>> DogsDB.DB | Distance     | Race type | TfGoing | Going  | Pos    | Btn
>>   |
>>            | Check _join2 | Check     | Check   | Check  | Check  | Check
>>   |
>>            | Check _join2 | Check     | Check   | Check  | Check  | Check
>>   |
>> 
>> DogsDB.DB | Trap   | Name         | Age    | Sex    | Bend.1 | Bend.2
|
>>            | Check  | Check _join1 | Check  | Check  | Check  | Check
 |
>>            | Check  | Check _join1 | Check  | Check  | Check  | Check
 |
>> 
>> DogsDB.DB | Bend.3 | Bend.4 | Comments | ISP    | TFR    | Official time
>> |
>> 			 | Check  | Check  | Check    | Check  | Check  | Check         |
>> 			 | Check  | Check  | Check    | Check  | Check  | Check         |
>> 
>> DogsDB.DB | Break time                  | Trainer | Betfair |
>>            | Check                       | Check   | Check   |
>>            | Check _b,calc _b*0 as RaceN | Check   | Check   |
>> 
>> EndQuery
>> 
>> 	  qb.executeQBE()
>>   play("RaceNo.ssl")
>> 
>>    qb=Query
>> ANSWER: :WORK:ANSWER.DB
>> 
>> Races.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
|
>> 
>>           | Check     | Check    | Check   | Check  | Check  | Check 
  |
>> 
>> 
>> Races.DB | Race type | TfGoing | Going  | Pos    | Btn    | Trap   | Name
>>    |
>>           | Check     | Check   | Check  | Check  | Check  | Check  |
Check
>>   |
>> 
>> Races.DB | Age    | Sex    | Bend.1 | Bend.2 | Bend.3 | Bend.4 | Comments
>> |
>>           | Check  | Check  | Check  | Check  | Check  | Check  | Check
>>   |
>> 
>> Races.DB | ISP    | TFR    | Official time | Break time | Trainer | Betfair
>> |
>> 			| Check  | Check  | Check         | Check      | Check   | Check  
|
>> 
>> Races.DB | Race name_1 | Racetime_1 | Race No_1 | Date_1 | Grade_1 |
>>           | Check       | Check      | Check     | Check  | Check   |
>> 
>> Races.DB | Distance_1 | Race type_1 | TfGoing_1 | Going_1 | Pos_1  | Btn_1
>>   |
>>           | Check      | Check       | Check     | Check   | Check  |
Check
>>   |
>> 
>> Races.DB | Trap_1 | Name_1 | Age_1  | Sex_1  | Bend.1_1 | Bend.2_1 | Bend.3_1
>> |
>> 			| Check  | Check  | Check  | Check  | Check    | Check    | Check 
  |
>> 
>> 
>> Races.DB | Bend.4_1 | Comments_1 | ISP_1  | TFR_1  | Official time_1 |
>> 			| Check    | Check      | Check  | Check  | Check           |
>> 
>> Races.DB | Break time_1 | Trainer_1 | Betfair_1 | RaceN         |
>> 			| Check        | Check     | Check     | Check >0,<=8 |
>> 
>> EndQuery
>> 
>> 	qb.executeQBE()
>> 
>> 
>> 	tab.attach("answer")
>> tab.add("Stats1",True,False)
>>      
>>   qb=Query
>> ANSWER: :WORK:NNett.DB
>> 
>> Stats1.DB | Race name | Racetime | Race No | Date   | Grade     | Distance
>>   |
>> 			 | Check     | Check    | Check   | Check  | Check A.. | Check 380
|
>> 
>> Stats1.DB | Race type | Pos    | Trap   | Name   | Age    | Sex    | ISP
>>     |
>> 			 | Check     | Check  | Check  | Check  | Check  | Check  | Check 
|
>> 
>> Stats1.DB | Betfair |
>> 			 | Check   |
>> 
>> Stats1.DB | TFR_1
>>                                                                      
   
>>                              |
>> 			 | _a,calc _a*0 as RT2,calc _a*0 as RT2P,calc _a*0 as RT2C,calc _a*0
as
>> RT4,calc _a*0 as RT4P,calc _a*0 as RT4C,calc _a*0 as RT6,calc _a*0 as
RT6P,calc
>> _a*0 as RT6C |
>> 
>> Stats1.DB |
>> 			 |
>> 
>> Stats1.DB | RaceN
>>                                                   |
>> 			 | calc _a*0 as BT6,calc _a*0 as RT6P,calc _a*0 as RT6Avg,calc _a*0
as
>> Tracp P,calc _a*0 as BT,calc _a*0 as Nocr |
>> 
>> EndQuery
>> 
>> 
>>    qb.executeQBE()
>> 
>> 
>> 	
>>   qb=Query
>> ANSWER: :WORK:Adjtimes.DB
>> 
>> Stats1.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
|
>> 
>> 			 | Check     | Check    | Check   | Check  | Check  | Check    |
>> 
>> Stats1.DB | Race type | TfGoing | Going  | Pos    | Btn    | Trap   |
Name
>>    |
>> 			 | Check     | Check   | Check  | Check  | Check  | Check  | Check
 |
>> 
>> 
>> Stats1.DB | Age    | Sex    | Bend.1 | Bend.2 | Bend.3 | Bend.4 | Comments
>> |
>> 			 | Check  | Check  | Check  | Check  | Check  | Check  | Check    |
>> 
>> Stats1.DB | ISP    | TFR    | Official time | Break time | Trainer | Betfair
>> |
>> 			 | Check  | Check  | Check         | Check      | Check   | Check 
 |
>> 
>> 
>> Stats1.DB | Race name_1  | Racetime_1   | Race No_1    | Date_1      
|
>> 			 | Check _join1 | Check _join2 | Check _join7 | Check _join4 |
>> 
>> Stats1.DB | Grade_1      | Distance_1   | Race type_1 | TfGoing_1 | Going_1
>> |
>> 			 | Check _join6 | Check _join5 | Check       | Check     | Check  
|
>> 
>> Stats1.DB | Pos_1  | Btn_1  | Trap_1 | Name_1 | Age_1  | Sex_1  | Bend.1_1
>> |
>> 			 | Check  | Check  | Check  | Check  | Check  | Check  | Check    |
>> 
>> Stats1.DB | Bend.2_1 | Bend.3_1 | Bend.4_1 | Comments_1 | ISP_1  | TFR_1
>>   |
>> 			 | Check    | Check    | Check    | Check      | Check  | Check  |
>> 
>> Stats1.DB | Official time_1 | Break time_1 | Trainer_1 | Betfair_1 | RaceN
>>   |
>> 			 | Check           | Check        | Check     | Check     | Check 
|
>> 
>> goingAllow.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
>> |
>> 				  | _join1    | _join2   | _join7  | _join4 | _join6 | _join5   |
>> 
>> goingAllow.DB | GA     |
>> 				  | Check  |
>> 
>> EndQuery
>> 
>> 
>>    qb.executeQBE()
>> 
>> 
>> 
>> 
>>   qb= Query
>> ANSWER: :WORK:Adjtimes.DB
>> 
>> 
>> Adjtimes.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
>> |
>> 				| Check     | Check    | Check   | Check  | Check  | Check    |
>> 
>> Adjtimes.DB | Race type | TfGoing | Going  | Pos    | Btn    | Trap  
|
>> 				| Check     | Check   | Check  | Check  | Check  | Check  |
>> 
>> Adjtimes.DB | Name   | Age    | Sex    | Bend.1 | Bend.2 | Bend.3 | Bend.4
>> |
>> 				| Check  | Check  | Check  | Check  | Check  | Check  | Check  |
>> 
>> Adjtimes.DB | Comments | ISP    | TFR    | Official time | Break time
|
>> 				| Check    | Check  | Check  | Check         | Check      |
>> 
>> Adjtimes.DB | Trainer | Betfair | Race name_1 | Racetime_1 | Race No_1
|
>> 
>> 				| Check   | Check   | Check       | Check      | Check     |
>> 
>> Adjtimes.DB | Date_1 | Grade_1 | Distance_1 | Race type_1 | TfGoing_1
|
>> 				| Check  | Check   | Check      | Check       | Check     |
>> 
>> Adjtimes.DB | Going_1 | Pos_1  | Btn_1  | Trap_1 | Name_1 | Age_1  | Sex_1
>>   |
>> 				| Check   | Check  | Check  | Check  | Check  | Check  | Check  |
>> 
>> Adjtimes.DB | Bend.1_1 | Bend.2_1 | Bend.3_1 | Bend.4_1 | Comments_1 |
ISP_1
>>   |
>> 				| Check    | Check    | Check    | Check    | Check      | Check 
|
>> 
>> Adjtimes.DB | TFR_1  | Official time_1 | Break time_1 | Trainer_1 | Betfair_1
>> |
>> 				| Check  | Check _a        | Check        | Check     | Check    
|
>> 
>> Adjtimes.DB | RaceN    | GA                         |
>> 				| Check >0 | Check _b,calc _a-_b as GAA |
>> 
>> EndQuery
>> 
>> 
>>    qb.executeQBE()
>> 
>>    qb=Query
>> ANSWER: :PRIV:ANSWER.DB
>> 
>> OPTIONS: NO AUXILIARY TABLES
>> Adjtimes.DB | Distance_1 | Official time_1 | GA | GAA            |
>> 				|            | _c              | _b | changeto _c+_b |
>> 
>> EndQuery
>> 
>> 	qb.executeQBE()
>> 
>>    qb=Query
>> ANSWER: :WORK:NNett.DB
>> 
>> DogsDB.DB | Race name     | Racetime | Race No | Date              | Grade
>>   | Distance  |
>> 			 | Check Crayford | Check    | Check   | Check ~sDate     | Check 
| Check
>> 380 |
>> 
>> DogsDB.DB | Race type | Pos    | Trap   | Name   | Age    | Sex    |
>> 			 | Check     | Check  | Check  | Check  | Check  | Check  |
>> 
>> DogsDB.DB | TFR
>>                                                                      
   
>>                              |
>> 			 | _a,calc _a*0 as RT2,calc _a*0 as RT2P,calc _a*0 as RT2C,calc _a*0
as
>> RT4,calc _a*0 as RT4P,calc _a*0 as RT4C,calc _a*0 as RT6,calc _a*0 as
RT6P,calc
>> _a*0 as RT6C |
>> 
>> DogsDB.DB |
>> 			 |
>> 
>> DogsDB.DB | Betfair
>>                                                         |
>> 			 | Check calc _a*0 as BT6,calc _a*0 as RT6P,calc _a*0 as RT6Avg,calc
_a*0
>> as Tracp P,calc _a*0 as BT,calc _a*0 as Nocr |
>> 
>> EndQuery
>> 
>>    qb.executeQBE()
>> 
>> 
>> 
>>   qb= Query
>> ANSWER: :PRIV:ANSWER.DB
>> 
>> NNett.DB | Pos              |
>> 			| not 1,changeto 0 |
>> 
>> EndQuery
>> 
>> 
>>    qb.executeQBE()
>> 
>> 	
>> 
>>   play("Lto2T.ssl")
>> 
>>   play("Lto4.ssl")
>> 
>>    play("Lto6.ssl")
>> 
>> 	play("BT8.ssl")
>> 	play("Fitness.ssl")
>> 
>>    qb=Query
>> ANSWER: :PRIV:ANSWER.DB
>> 
>> OPTIONS: NO AUXILIARY TABLES
>> NNett.DB | Race name | Racetime | Race No | Date   | Name   | Betfair
>>   |
>> 			| _join1    | _join2   | _join3  | _join4 | _join5 | changeto _a |
>> 
>> BetfairSp.DB | Race name | Racetime | Race No | Date   | Name   | Betfair
>> |
>> 				 | _join1    | _join2   | _join3  | _join4 | _join5 | _a      |
>> 
>> EndQuery
>> 
>>    qb.executeQBE()
>> 
>> 	 qb=Query
>> ANSWER: :WORK:ANSWER.DB
>> 
>> NNett.DB | Race name | Racetime | Race No | Date   | Grade  | Distance
|
>> 
>>           | Check     | Check    | Check   | Check  | Check  | Check 
  |
>> 
>> 
>> NNett.DB | Race type | Pos    | Trap   | Name   | Age    | Sex    | Betfair
>> |
>>           | Check     | Check  | Check  | Check  | Check  | Check  | Check
>>    |
>> 
>> NNett.DB | RT2    | RT2P   | RT2C   | RT4    | RT4P   | RT4C   | RT6 
  |
>> 
>>           | Check  | Check  | Check  | Check  | Check  | Check  | Check
 |
>> 
>> 
>> NNett.DB | RT6P   | RT6C   | BT6    | RT6P_1 | RT6Avg | Tracp P | BT
>> |
>>           | Check  | Check  | Check  | Check  | Check  | Check   | Check
>> |
>> 
>> NNett.DB | Nocr   |
>>           | Check  |
>> 
>> EndQuery
>> 
>> 	  qb.executeQBE()
>>    	tab.attach("answer")
>> tab.add("Stats2",True,False)
>>   
>> 
>> 
>> 			
>> 
>> 		; and at the end prepare data for next iteration
>> 		dStart = dEnd+1
>> 		mStart = mEnd+1
>> 	
>> 	endWhile
>> 
>> 


Copyright © 2004 thedbcommunity.com