Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select last data
Message
From
09/06/2006 02:48:57
 
 
To
08/06/2006 21:11:07
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01128007
Message ID:
01128052
Views:
22
>Hello all,
>
>How to select last month data from mytable.dbf ?
>
>mytable.dbf
>
>daterequired   idnumber  lastname firstname
>
>2006/05/27     11111     bloe      joe
>2006/06/26     22222     hungry    brian
>2006/05/19     33333     keeper    goalie
>2006/04/18     44444     defence   legs
>
>Suppose to have in mynewtable :
>
>2006/05/27     11111     bloe      joe
>2006/05/19     33333     keeper    goalie
>
>I try this but not sure about syntax in SQL statments:
>
>Select * from mytable into mynewtable where month(daterequired) = subs(daterequired,5,2).
>
>TIA

Don't forget about your data type transformations. Assuming you want the data from the month previous to the current date....
ldDate = DATE()
SELECT * FROM mytable ;
 WHERE PADR(month(ldDate)-1,2,'0') = SUBSTR(mytable.daterequired,6,2) ;
   AND TRANS(YEAR(ldDate)) = LEFT(mytable.daterequired,4);
 INTO CURSOR/DBF mynewtable
Previous
Reply
Map
View

Click here to load this message in the networking platform