June 28, 2018 at 3:19 am
Hi,
The output from my Time field in my query is 2015-01-07 10:33:00.000.
I would like my query to output the Time only. My query is: Select DateOfvisit, Team, DatePart(Hour,TimeOfVisit) As HourSlot, Count(*) As Visits from events
Thanks
June 28, 2018 at 3:23 am
Unsure which column you want the time only in your query, but add or replace with cast(TimeOfVisit as TIME)
This will give you hh:mm:ss.nnnnn
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle
June 28, 2018 at 3:39 am
Thanks is there anyway to remove the seconds?
June 28, 2018 at 4:35 am
Yes, use CONVERT(VARCHAR(5),TimeOfVisit,108)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle
June 28, 2018 at 5:49 am
Thank you
June 28, 2018 at 1:31 pm
Henrico Bekker - Thursday, June 28, 2018 4:35 AMYes, use
CONVERT(VARCHAR(5),TimeOfVisit,108)
Consider the eventual "Death by a thousand cuts" that every database ends up going through and use CHAR(5) instead of VARCHAR(5).
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy