Table filter from date to date

Standa

Member
Licensed User
Longtime User
Hello,
I have table where one row of record contains date in format "yyyy-mm-dd". Is there some way how to make filter, for example from 7th month 2008th year to 3th month 2009th year?
 

maXim

Active Member
Licensed User
Longtime User
Hi Standa,

you're working with a database SQL-92 compatible o more?​

The date field is a string?​

If the date field is a string (not a date format) then:​

B4X:
[LEFT][FONT=Courier New][COLOR=black][COLOR=purple]q_Date_Start[/COLOR] = "[B]2008-07-01[/B]"[/COLOR][/FONT]
[FONT=Courier New][COLOR=black][COLOR=purple]q_Date_End[/COLOR] = "[B]2009-03-30[/B]"[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]xSQL = "[B]SELECT * FROM[/B] [I][COLOR=sienna][your table][/COLOR][/I][B] WHERE (([/B][I][COLOR=sienna][date field][/COLOR][/I] [B]>= '[/B]" & [COLOR=purple]q_Date_Start[/COLOR] & "[B]') AND ([/B][I][COLOR=sienna][date field][/COLOR][/I][B] <= '[/B]" & [COLOR=purple]q_Date_End[/COLOR] & "[B]'))[/B]"[/COLOR][/FONT][/LEFT]
 
Last edited:

Standa

Member
Licensed User
Longtime User
Hi maXim,
there is little problem , I have used only simple table control, not sql. Because in the table will be not more than 250 records a year.
So is this filtering possible in the table control or have I use sql?
And yes, date is string format.
 
Last edited:

specci48

Well-Known Member
Licensed User
Longtime User
Hello Standa,

it is not possible to filter a "range" from a column which type is "cString".

A possible solution is to add a hidden table column (width = 0) of the type cNumber which contains the time or date information saved in ticks. This column could now be filtered easily for time ranges.


specci48
 

Standa

Member
Licensed User
Longtime User
Hey specci48 thank you!
This is what I already thought about - to make hidden column with cNumber value, but I did not know, how to make hidden column. Trick with width = 0 is smart, thank you .
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…