Solved

filter and TdateTime Field

Posted on 1998-06-24
12
481 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

791 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