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?
Try,
select convert (varchar(12), GetDate(), 101)
"Atley" <atley_1@.homtmail.com> wrote in message
news:%2315icKpEEHA.2640@.TK2MSFTNGP09.phx.gbl...
> 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?
>
>
|||convert (char(10), GetDate(), 111)
"Atley" <atley_1@.homtmail.com> wrote in message
news:%2315icKpEEHA.2640@.TK2MSFTNGP09.phx.gbl...
> 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?
>
>
|||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
"Atley" <atley_1@.homtmail.com> wrote in message news:%2315icKpEEHA.2640@.TK2MSFTNGP09.phx.gbl...
> 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?
>
>
|||> I have tried convert (datetime, GetDate(), 112) and some others, all to no
> avail...
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)
> isn't there just a date function that doesn't include the time?
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/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment