Home > Archive > MS SQL Server > February 2006 > Cast DateTime To Date?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Cast DateTime To Date?
Lee

2006-02-06, 7:23 am



I have a datetime field in a database, but want to query on the date
portion only.

1. Can someone provide an example?
2. Any good online SQL resources specific to MSSQL dialect?

Thank you,

--
Warm Regards,
Lee

"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."
Jens

2006-02-06, 7:23 am

1. Can someone provide an example?

Sure, SELECT CONVERT(VARCHAR(10),
GETDATE(),112) --Look in the BOL for
more information about Convert.


2. Any good online SQL resources specific to MSSQL dialect?

Sure, look in the BOL for more information: http://www.aspfaq.com/2229

HTH, jens Suessmeyer.

Sreejith G

2006-02-06, 9:23 am

Datetime to Date =>

This will work,

SELECT getdate()
SELECT CAST(FLOOR(CAST( getdate() AS float)) AS DATETIME)

For MSSQL dialect, look BOL

Thanks,
Sree


"Lee" wrote:

>
>
> I have a datetime field in a database, but want to query on the date
> portion only.
>
> 1. Can someone provide an example?
> 2. Any good online SQL resources specific to MSSQL dialect?
>
> Thank you,
>
> --
> Warm Regards,
> Lee
>
> "Upon further investigation it appears that your software is missing
> just one thing. It definitely needs more cow bell..."
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com