Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 To: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 Tags
Subject: RE: Selecting by date
Thread ID: 288634 Message ID: 288918 # Views: 28 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Grids
Date: Sunday, December 26, 2010 1:27:09 PM         
   


> > If I have a date time field, and just for an example, if I want to filter based on an American date of 12/21/2010, how would I enter the filter statement?
> >
> > I've tried with various methods and functions, and none seem to get me there. A couple examples I have tried, with the field name being tdate, are:
> >
> >
SET FILTER TO ttod(tdate) = {^12/21/10}
> > SET FILTER TO tdate = {12/18/2010}
> > SET FILTER TO tdate = {^2010-12-18}

> >
> > Thanks
>
> Assuming 'set filter' is a command one would want to use (I never use):
>
>
set filter to tDate >= date(2010,12,21) and tDate < date(2010,12,22)

>
> or:
>
>
set filter to ttod(tDate) = date(2010,12,21)

>
> or:
>
>
set filter to cast(tDate as date) = date(2010,12,21)
> 

>
> What you choose depends on what indexes you have. Remember to benefit from Rushmore you need to have an expression that matches an existing index key. If you don't have an index created like:
>
>
index on cast(tDate as date) tag ByDate

>
> you wouldn't want to use the last one. First one although harder to write, matches to a simple index on tDate field.
>
> PS: And BTW you may want to convert and assign the right side to a variable. With filter it would affect slightly because of how set filter evaluation works.

Did you mean convert to datetime?
d1=datetime(2010,12,21,00,00,00)
d2=date(2010,12,22)  && Or would this be enough?
set filter to tDate >= d1 and tDate < d2





>
> Cetin Basoz
>
> .Net has got better.Think about moving - check my blog:
> Blog (main)
> Blog (mirror)



Regards
Samir

ENTIRE THREAD

Selecting by date Posted by Rog @ 12/22/2010 8:40:21 PM
RE: Selecting by date Posted by Anders Altberg @ 12/22/2010 8:54:00 PM
RE: Selecting by date Posted by Rog @ 12/22/2010 10:27:39 PM
RE: Selecting by date Posted by Luis Maria Guayan @ 12/22/2010 11:07:58 PM
RE: Selecting by date Posted by Anders Altberg @ 12/23/2010 12:21:04 AM
RE: Selecting by date Posted by Christian Tabligan @ 12/23/2010 9:13:49 AM
RE: Selecting by date Posted by Anders Altberg @ 12/23/2010 2:46:01 PM
RE: Selecting by date Posted by Christian Tabligan @ 12/24/2010 2:58:55 AM
RE: Selecting by date Posted by Anders Altberg @ 12/24/2010 1:37:10 PM
RE: Selecting by date Posted by Christian Tabligan @ 12/25/2010 9:27:41 AM
RE: Selecting by date Posted by Cetin Basoz @ 12/23/2010 10:08:56 AM
RE: Selecting by date Posted by Samir H. @ 12/26/2010 1:27:09 PM
RE: Selecting by date Posted by Cetin Basoz @ 12/26/2010 6:00:24 PM