May 5, 2008 at 12:56 pm
I have a table which includes:
EventID (int, primary key)
EventDate (smalldatetime)
EventLocation (vachar(50)
I would like to run a query that will show the date only without the time included and the event location. Is this possible?
Example query: EventID, 01/01/2008, Running Spring Village
May 5, 2008 at 12:58 pm
Yes, but I would use convert...
Below is how i used it in a where clause, for reference I have attached the link for Converting Dates. Link> http://msdn.microsoft.com/en-us/library/ms187928.aspx
(CONVERT(Varchar, dbo.Dial.LastCalled, 103) = CONVERT(Varchar, GETDATE(), 103))
May 5, 2008 at 1:02 pm
For example:
Select EventID, EventDate, Convert(Varchar, EventLocation, 103) As EventDate
From Table name
The 103 tells the convert how to present the data, use the link I posted eailer to get different examples of how to display the date, 103 displays as dd/mm/yyyy
May 5, 2008 at 1:22 pm
I execute the following query as advised and results was:
EventID EventDate EventDate
1 2008-01-01 00:00:00 Running Spring Village
2 2008-02-02 00:00:00 North Valley Park
3 2008-03-03 00:00:00 South Park Rec.
The time stamp still show in the query.
May 5, 2008 at 1:25 pm
I got it. Thank you very much for your help. I made a few changes in the query.
SELECT EventID, EventLocation, Convert(Varchar, EventDate, 103) AS EventDate
FROM Event
Works like a charm.:D
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply