Groups | Blog | Home
all groups > sql server data mining > march 2004 >

sql server data mining : Getting Just The Date


Prasad Koukuntla
3/25/2004 12:02:54 PM
Try,

select convert (varchar(12), GetDate(), 101)

[quoted text, click to view]

Raymond D'Anjou (raydan)
3/25/2004 12:51:34 PM
convert (char(10), GetDate(), 111)

[quoted text, click to view]

Atley
3/25/2004 12:57:00 PM
This sounds stupid, but I cannot find a way to just get today's date without
the time to pull a date range...

I have tried convert (datetime, GetDate(), 112) and some others, all to no
avail... isn't there just a date function that doesn't include the time?


Aaron Bertrand [MVP]
3/25/2004 1:35:46 PM
[quoted text, click to view]

How exactly did you try this? What does "to no avail" mean?

Here is how I would retrieve all the rows that have a datetime within today.

DECLARE @dt SMALLDATETIME
SET @dt = {fn CURDATE()}
SELECT cols
FROM tbl
WHERE dtCol >= @dt
AND dtCol < (@dt + 1)

[quoted text, click to view]

SELECT {fn CURDATE()}

SELECT CONVERT(SMALLDATETIME,
CONVERT(CHAR(8), GETDATE(), 112))


Why is this posted to clients and datamining? Follow-ups adjusted.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/

Tibor Karaszi
3/25/2004 7:04:00 PM
You need to use a convert and convert it into a string. There is no date-only datatype in SQL Server. You can
of course have a datetime with time 00:00:00, but there's still a time portion.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp


[quoted text, click to view]

AddThis Social Bookmark Button