Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filtering a date
Message
From
29/10/2009 02:56:57
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01432041
Message ID:
01432165
Views:
49
>>Dear All,
>>I have a table with a date field with different date of course
>>will it be possible to filter a specific month from the date field
>>table structure
>>
>>Idnumber n(10)
>>Employee c(40)
>>entrancedate d(8)
>>exitdate d(8)
>>
>>I want to filter for the month of November or any month the the exit date of the employee
>>Thank you
>
>Say, you pass month and year as two numbers
>
>Select * from myTable where ExitDate between 
>date(1,PassedMonth, PassedYear) and gomonth(date(1,PassedMonth, PassedYear),1) 
>into cursor curResults nofilter
>
>If you need it as a filter then
>
>SET FILTER TO between(ExitDate, date(1,PassedMonth, PassedYear), gomonth(date(1,PassedMonth, PassedYear),1) )
>
>assuming you may have an index on the date field.
>SET FILTER TO between(ExitDate, date(1,PassedMonth, PassedYear), gomonth(date(1,PassedMonth, PassedYear),1) )
I would rather use macro expansion to get rid of the variables. What happens when PassedMonth and PassedYear go out of scope ?
local date1, date2

date1 = DateTransform(date(1,PassedMonth, PassedYear))
date2 = DateTransform(gomonth(date(1,PassedMonth, PassedYear),1)  - 1)

set filter to between(ExitDate, &date1, &date2)


function DateTransform(d)

	return transf(dtos(m.d), '@R {^####/##/##') + '}'
endfunc
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform