The best way I have found is to CONVERT to VARCHAR, then CONVERT the VARCHAR
to DATETIME:
CONVERT (DATETIME, CONVERT (VARCHAR(255), logged, 101))
will extract out the date portion only.
Regards,
Dennis.
> -----Original Message-----
> I could not find any simple DatePart function in MSSQL to extract date
> portion from datetime columns.
> What is the best way to compare dates with the values in the
> datetime column
> ignoring its time portion ?
>
> I found this working but a bit ugly:
>
> Say I want records from 1/05/2000 to 30/05/2000 and my logged
> column is of
> datetime type.
>
> SELECT * FROM mytable WHERE DATEDIFF(day, logged,
> '2000-05-01') <= 0 and
> DATEDIFF(day, logged, '2000-05-30') >= 0
>
> Any better ways to do this ?
>
>
> Thanks
> Alex
>
> --------------------------------------------------------------
> -------------
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz