Solved

filter and TdateTime Field

Posted on 1998-06-24
12
482 Views
Last Modified: 2010-04-04
hi
how can i made filter on TdateTime Field ?
(i tried to enter to the Filter property MYDateTime='01/01/90' but Delphi does not except it )
10x in advance
asi
0
Comment
Question by:asi
[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
  • 6
  • 5
12 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1355589
Hi,
Did you set the FilterOptions to [foCaseInsensitive]? Other solution is to write OnFilterRecord procedure which you can control record filtering in a dynamic way.
Or you may use a querry of type
SELECT * FROM MYTABLE WHERE MYDATETIME = '01/01/90'
Regards, Igor
0
 

Author Comment

by:asi
ID: 1355590
its not working , igor

(and the other options is not relevant ...

10x anyway
0
 
LVL 1

Expert Comment

by:michaue
ID: 1355591
What did you mean it did not except it
- did you get an error message
- did it just not filter anything
- didn't you get any records back at all

Things to check
- is your filtered property set to true
- if you filtered during run-time is your syntax correct for example

  table1.filter := 'DATE_OF_BIRTH = ''12/30/74''';
  table1.filtered := True;

  You need all the extra ' (whatever you call them, sorry my home language is not english)

Hope it works
Have fun
Elfrieda :)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
michaue earned 20 total points
ID: 1355592
What did you mean it did not except it
     - did you get an error message
     - did it just not filter anything
     - didn't you get any records back at all

     Things to check
     - is your filtered property set to true
     - if you filtered during run-time is your syntax correct for example

       table1.filter := 'DATE_OF_BIRTH = ''12/30/74''';
       table1.filtered := True;

       You need all the extra ' (whatever you call them, sorry my home language is
       not english)

     Hope it works
     Have fun
     Elfrieda :)
0
 

Author Comment

by:asi
ID: 1355593
i did exectly like u told me and i got an err '12/30/74' is not an valid date
can u send me an samll example
b_asi@inter.net.il
10x


0
 
LVL 1

Expert Comment

by:michaue
ID: 1355594
Ok, then we're making progress...

You'll now have to put some dummy code into your program to see how your date and time is set up.

Set up some code behind a button or something to store the current date in your database field and then go into your database desktop to see the format.  You need to have the format correct to get the procedure to work properly

etc.  <your date field in your table> := Date;

Otherwise you can add a record manually through the database desktop to hold the current date (derived from Date) in the field you want filtered and build up the filter string as follows :

 table1.filter := 'DATE_OF_BIRTH = ''' + DateToStr(Date) + '''';
 table1.filtered := True;

Elfrieda :)

0
 

Author Comment

by:asi
ID: 1355595
i tried all the options

   table1.filter := 'WeekStart = ''' + DateToStr(Date) + '''';    //25-June-98 is not a valid date
   Table1.filter:='WeekStart = ''' + '01/01/98' + ''''; // 01/01/98 is not a valid date

0
 
LVL 1

Expert Comment

by:michaue
ID: 1355596
- what kind of database are you working with
- how is your WeekStart declared in the table
- what component (eg TDBGrid) are you using to display the data currently

Elfrieda :)

PS : Mine is working (I wrote a small dummy application), so we will figure out your problem
0
 

Author Comment

by:asi
ID: 1355597
hi
i use a local paradox database
WeekStart is declare as Type D - Date
i"m using Tdbgrid but this is not the problem as far as i understand (because of your remard i even remove the dbgrid control and stile the problem exist
10x
asi
0
 
LVL 1

Expert Comment

by:michaue
ID: 1355598
Ok,

If you program is not that bit, email me the whole project, and I'll have a look at it ...

elfrieda@ats.sani.org

Elfrieda :)
0
 
LVL 1

Expert Comment

by:michaue
ID: 1355599
If you don't want to send the whole program, we can think of something else, just let me know?

We'll sort this out for you ...

Elfrieda :)
0
 

Author Comment

by:asi
ID: 1355600
Hi

First of all I want to thank u a lot 4 your kindness
I find the bug

In my computer windows definition the date format was
dd-mmm-yyyy
so I just change it to my format dd/mm/yy and all the problem fixed
(and since I type date as 01/01/90 the computer did not recived it)

10x again 4 your help

Asi
I'll give u anyway the pointes 4your help



0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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