Board index » delphi » Filtering by the date

Filtering by the date

Hello

I have table with a column with the Date or an event! Dates in IB are stored
with the time right?

I would like to a set of data for one day in particular!

But if I :

  IBView->ParamByName("Date")->AsDate = StrToDate("25-03-2003");

when I open the View I have zero record because on the table I have
25-03-2003 2:56:35 and I think that StrToDate("25-03-2003") is being
considered "25-03-2003 00:00:00" !am I worng?

I know that I coul dresolve this with some trick like incrementeing one day
to tha date and do something like: where day >= "25-03-2003" and day <
"26-03-2003" but I wonder igf there is not a more 'direct' way of doing this

that a lot for the help

regards

Miguel

 

Re:Filtering by the date


Quote
Miguel wrote:
>   IBView->ParamByName("Date")->AsDate = StrToDate("25-03-2003");

> when I open the View I have zero record because on the table I have
> 25-03-2003 2:56:35 and I think that StrToDate("25-03-2003") is being
> considered "25-03-2003 00:00:00" !am I worng?

        You're correct.

Quote

> I know that I coul dresolve this with some trick like incrementeing
> one day to tha date and do something like: where day >= "25-03-2003"
> and day < "26-03-2003" but I wonder igf there is not a more 'direct'
> way of doing this

        The only "more direct" way is to store the date and times in separate
columns.

        -Craig

--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
InterBase Perf. Monitor : http://delphi.weblogs.com/IBPerformanceMonitor
InterBase PLANalyzer 1.1: http://delphi.weblogs.com/IBPLANalyzer

Re:Filtering by the date


"Craig Stuntz [TeamB]" <cstu...@vertexsoftware.com> escreveu na mensagem
news:3e8076e1@newsgroups.borland.com...

Quote
> Miguel wrote:

> >   IBView->ParamByName("Date")->AsDate = StrToDate("25-03-2003");

> > when I open the View I have zero record because on the table I have
> > 25-03-2003 2:56:35 and I think that StrToDate("25-03-2003") is being
> > considered "25-03-2003 00:00:00" !am I worng?

> You're correct.

> > I know that I coul dresolve this with some trick like incrementeing
> > one day to tha date and do something like: where day >= "25-03-2003"
> > and day < "26-03-2003" but I wonder igf there is not a more 'direct'
> > way of doing this

> The only "more direct" way is to store the date and times in separate
> columns.

> -Craig

> --
> Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
> Delphi/InterBase Weblog : http://delphi.weblogs.com
> InterBase Perf. Monitor : http://delphi.weblogs.com/IBPerformanceMonitor
> InterBase PLANalyzer 1.1: http://delphi.weblogs.com/IBPLANalyzer

Re:Filtering by the date


Actualy you don't need any "trick"....
...You can always do a query like that:

select "my_fields" from "my_table"
where cast("my_datetime_field" as date) = 'mm-dd-yy'

or

select "my_fields" from "my_table"
where cast("my_datetime_field" as date) = :my_date_param

Regards,
Anderson

"Miguel" <mig...@nospam.trigenius.pt> escreveu na mensagem
news:3e8071ed$1@newsgroups.borland.com...

Quote
> Hello

> I have table with a column with the Date or an event! Dates in IB are
stored
> with the time right?

> I would like to a set of data for one day in particular!

> But if I :

>   IBView->ParamByName("Date")->AsDate = StrToDate("25-03-2003");

> when I open the View I have zero record because on the table I have
> 25-03-2003 2:56:35 and I think that StrToDate("25-03-2003") is being
> considered "25-03-2003 00:00:00" !am I worng?

> I know that I coul dresolve this with some trick like incrementeing one
day
> to tha date and do something like: where day >= "25-03-2003" and day <
> "26-03-2003" but I wonder igf there is not a more 'direct' way of doing
this

> that a lot for the help

> regards

> Miguel

Re:Filtering by the date


Thanks for your advise!  :-)

Regards,
Anderson

"Craig Stuntz [TeamB]" <cstu...@vertexsoftware.com> escreveu na mensagem
news:3e81ca02$2@newsgroups.borland.com...

Quote
> Anderson wrote:

> > Actualy you don't need any "trick"....
> > ...You can always do a query like that:

> > select "my_fields" from "my_table"
> > where cast("my_datetime_field" as date) = 'mm-dd-yy'

> > or

> > select "my_fields" from "my_table"
> > where cast("my_datetime_field" as date) = :my_date_param

> Thus preventing your query from using an index.  Both of the other
> solutions presented can use an index.

> -Craig

> --
> Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
> Delphi/InterBase Weblog : http://delphi.weblogs.com
> InterBase Perf. Monitor : http://delphi.weblogs.com/IBPerformanceMonitor
> InterBase PLANalyzer 1.1: http://delphi.weblogs.com/IBPLANalyzer

Re:Filtering by the date


Quote
Anderson wrote:
> Actualy you don't need any "trick"....
> ...You can always do a query like that:

> select "my_fields" from "my_table"
> where cast("my_datetime_field" as date) = 'mm-dd-yy'

> or

> select "my_fields" from "my_table"
> where cast("my_datetime_field" as date) = :my_date_param

        Thus preventing your query from using an index.  Both of the other
solutions presented can use an index.

        -Craig

--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
InterBase Perf. Monitor : http://delphi.weblogs.com/IBPerformanceMonitor
InterBase PLANalyzer 1.1: http://delphi.weblogs.com/IBPLANalyzer

Other Threads