Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Table1.Filter??

Posted on 2001-06-30
9
Medium Priority
?
2,101 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

705 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