Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Table1.Filter??

Posted on 2001-06-30
9
Medium Priority
?
2,129 Views
Last Modified: 2012-06-21
I want to filter my database with;
Table1.Filter := 'NAME = DateToStr(DateTimePicker1.Date);
Table1.Filtered := True;

But it says

Table1: Field 'DateToStr'not found...

But if i try
Table1.Filter := 'NAME = ''SYS''';
Table1.Filtered := True;

it works. But i want user choose date to filter? How can i do this??
0
Comment
Question by:systemop
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 1

Expert Comment

by:cobramania
ID: 6240833
try set that at run time
Table1.Filter := 'NAME = DateToStr(DateTimePicker1.Date);
not design time

or try
dtTemp:= DateToStr(DateTimePicker1.Date);
Table1.Filter := 'NAME = dtTemp;

at runtime

hope this helps
0
 

Author Comment

by:systemop
ID: 6240875
neither of them works..
0
 
LVL 1

Expert Comment

by:cobramania
ID: 6240973
i don't have delphi in my comp now,
Table1.Filter shouldn't have variable

try this:

str:= 'Name='+DateToStr(DateTimePicker1.Date);
Table1.Filter := str;

hope this helps:)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6240994
near cobramania,
but i would guess it should be

str:= 'Name='+QuotedStr(DateToStr(DateTimePicker1.Date));
Table1.Filter := str;
Table1.Filtered := True;

meikl ;-)
0
 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 6240997
Thats works correctly try it.



Europe
Table.Filter:='My_Date >= '+''''+formatDateTime('dd/mm/yyyy',fIni)+'''';
Table1.Filtered:=True;

America
Table.Filter:='My_Date >= '+''''+formatDateTime('mm/dd/yyyy',fIni)+'''';
Table1.Filtered:=True;
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6241279
The format of date has to meet the requirements of the database as well.

Access wants the date to surrounded by the number symbol instead of quotes. Something this
#mm/dd/yyyy#

And Sybase wants the format to be yyyy/mm/dd.

I believe Paradox is mm/dd/yyyy.

Because of these variants and in my opinion I think you would be better served if you used a Query instead of a Table for filtering dates so you could use the Params property instead of the Filter property.


The Crazy One
0
 

Accepted Solution

by:
ondertol earned 150 total points
ID: 6241421
You must write the Filter String as this format:

Table1.Filter := 'Name = ''' + DateToStrDateTimePicker1.Date) + '''';

where "Name" is the field name of your table;


If you want filtered your table with fixed date, can you write this string on property Filter on object inspector :

Name = '12/10/01' <--- this is a string constant

if you write this code on program, the same istruction is

Table1.Filter := 'Name = '' 12/10/01 '' ';
                 

The first and the last ' indicate at the Delphi compiler  
                         who this is a string value
the double '' is used into a string for indicate only one '

Now, if you examinate the first istruction of this comment can you understand the meaning:

the first ' is used for indicate: i have open one string
Name =, show the field name of table
into ''': the compiler translate two first '' at only
          one ' and the third ' is used for close
          the first part of string
DateToStr(...) return your date in string format (second
               part of string)
into '''': the first and the last ' il used for open and  
           close the third part of string and
           the central '' is translate by compiler
           to only one '

the istrunction, when is compiled is translate on this format:
table1.Filter := ' Name = '10/12/01' ';

if the value of DateTimePicker1.Date is 10/12/01

!!!!remember: set the Filtered property = True
0
 

Author Comment

by:systemop
ID: 6243906
Thank you ondertol
0
 

Expert Comment

by:ondertol
ID: 6246338
:-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question