August 4, 2005 at 1:55 pm
How do I select just the date part of a datetime row in my database?
August 4, 2005 at 2:07 pm
Select convert(varchar(10), getdate(), 110)
Check out BOLS if you need a different formating (under convert/datetime and see which value you need to use instead of 110).
August 4, 2005 at 2:20 pm
SET NOCOUNT ON
DECLARE @CTR INT
SET @CTR = 100
WHILE @CTR < 125
BEGIN
SELECT CONVERT(VARCHAR(10), GETDATE(), @CTR) [DATEFORMAT], @CTR
SET @CTR = @CTR + 1
END
or
Do you want datepart
SELECT DATEPART(DD, GETDATE())
SELECT DATEPART(D, GETDATE())
SELECT DATEPART(DAY, GETDATE())
Regards,
gova
August 4, 2005 at 2:36 pm
I just want the date (1/1/1900) part of the row instead of the date and time (1/1/1900 12:00)
My statement is a basic SELECT statement
August 4, 2005 at 2:38 pm
I'd tell you which one it is but since there's no difference between the months/days I'll have to let you find which convert to use. You'll really have to do some searching for this one.
August 5, 2005 at 2:07 am
This one gives you the date without the time:
SELECT CONVERT(DATETIME, FLOOR( CONVERT(FLOAT, GETDATE()) ))
But, as SQL Server still has no separate date and time types ( ), you get a time portion of 00:00.
When you don't want to see the time part you can use the CONVERT code as Remi says.
Depending on the country you live it is in the mm/dd/yyyy, dd/mm/yyyy, yyyymmdd, etc format.
Look in BOL (Books On Line) for the number that shows you the wanted format, eg. 101 (USA mm/dd/yyyy), 105 (British/French dd/mm/yyyy) or 112 (ISO yyyymmdd).
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply