Solved

Table1.Filter??

Posted on 2001-06-30
9
2,041 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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 50 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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