April 11, 2002 at 8:17 am
Hi,
Is there anyway in SQL statement to retrieve only the date value from a datetime datatype column? I have tried using datevalue(), to_date() function but seems like it doesn't work in SQL server.
Thanks.
~SG
April 11, 2002 at 8:28 am
Use gatdate() instead. There is plenty of samples in books-on-line. but just in case here is one:
SELECT Getdate()
GO
Returns today's date and time
If the question is regarding a specific date field, then you need to do,
SELECT [datetimefieldname]
FROM [tablename]
this returns all the column values you have stored in the table. The you can add
WHERE [datetimefieldname] between [Start date you need] AND [end date] to get only those records for a date range. and so on.
Good luck
April 11, 2002 at 8:52 am
Thanks. what about if i want to retrieve only the date,
for example the datetime '1/1/2002 11:00:00', is there a SQL function to retrieve only '1/1/2002', ignoring the time?
April 11, 2002 at 8:59 am
No but you can do CONVERT(VARCHAR,GETDATE(),101) or parse it manually.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply