> > What is the best way to summarise data from a datetime field in SQL
> >
> > The dbf has, say, the following data in a datetime field :
> >
> > 01/01/08 12:01:00
> > 01/01/08 2:00:00
> > 02/01/08 1:05:00
> > 03/01/08 5:01:00
> >
> > If I Select the dbf with GROUP BY, I get the 4 records, ie. the same as above.
>
> With a FoxPro backend(?) you can use Cast()
>
CREATE CURSOR temp (test T)
> INSERT INTO temp VALUES (DATETIME())
> INSERT INTO temp VALUES (DATETIME()-3600)
> BROWSE
> SELECT distinct CAST(test As Date) as date__ from temp
>
>
> > But, what I want is just the 3 dates, ie.
> > 01/01/08
> > 02/01/08
> > 03/01/08
> >
> > 1. Is it possible to use GROUP BY to get the desired result ?
>
> Yes (similar to the "Distinct" approach above).
>
> > and
> > 2. How do you get the date portion from the datetime field ?
>
> You can use TToD()
>
>
> hth
> -Stefan
Assume that CAST is in newer versions of VFP
Thanks anyway
Phillip