date part of getdate
-
i want to use the date part of the function getdate in my sql query. the getdate function return the current date and time. i want only the date part. how can i do it.
Goodway, First of all I assume you use SQL Server (7.0/2000). If not quit reading. Then, SQL Servers date/time datatype always consists of a date AND a time part. A date without a time component does not exsist is SQL Server. If you insert a date value without a time, for example jan 1, 2004, SQL Server inserts the date as 2004/01/01 00:00:00.000 (for smalldatetime skip the milliseconds). So if you need a date without a time you need to convert a datetime value to a string. You can use the CONVERT-function in SQL (see "CAST and CONVERT" in SQL Books online). Example: SELECT CONVERT (varchar(24), GetDate() , 103); Returns: 01/01/2004 -- Note: the result is a string. Not a datetime value. Good luck