Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Findout year except given year
Message
From
15/04/2005 09:01:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
15/04/2005 00:00:54
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01004465
Message ID:
01005063
Views:
19
SELECT * FROM YourTable WHERE YEAR(YourTable.YourDateField) < 2004 INTO CURSOR cCursor

The part in the code above, which I put in bold, is the condition that selects records. It can be replaced by many other conditions, depending exactly what you want. For example:

year(Table.DateField) # 2005 will select records from any year, except 2005.

not between(year(DateField), 2003, 2005) will select all records, except for years 2003-2005.

not inlist(year(DateField), 2002, 2004, 2006) will select records for all years except for the years specified (2002, 2004, 2006).

You can even have the years which you want excluded in a table, and use a subquery as follows:
SELECT * FROM YourTable WHERE YEAR(YourTable.YourDateField) not in (select Year from ExcludedYears)
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform