May 17, 2013 at 5:02 am
--Question 4b
select
History_Type_,
TimeClicked,
left(right(TimeClicked,11),2) as HourTimeClicked,
count(left(right(TimeClicked,11),2)) as CountOfHourTimeClicked
from clicktracking_ --with (nolock)
inner join members_ on clicktracking_.MemberID_ = Members_.MemberID_
group by
History_Type_,
timeClicked,
left(right(TimeClicked,11),2)
OPN2011-09-24 18:38:000169
OPN1802013-04-02 12:41:00011
OPN902013-04-11 18:18:00011
OPN1802011-09-26 13:08:000113
OPN902011-07-05 11:01:000117
the hour is always incorrectly 01 which is wrong
please can someone help?
May 17, 2013 at 5:41 am
philip.davy (5/17/2013)
--Question 4bselect
History_Type_,
TimeClicked,
left(right(TimeClicked,11),2) as HourTimeClicked,
count(left(right(TimeClicked,11),2)) as CountOfHourTimeClicked
from clicktracking_ --with (nolock)
inner join members_ on clicktracking_.MemberID_ = Members_.MemberID_
group by
History_Type_,
timeClicked,
left(right(TimeClicked,11),2)
OPN2011-09-24 18:38:000169
OPN1802013-04-02 12:41:00011
OPN902013-04-11 18:18:00011
OPN1802011-09-26 13:08:000113
OPN902011-07-05 11:01:000117
the hour is always incorrectly 01 which is wrong
please can someone help?
Don't try to parse datetime as string. Use relevant datetime functions instead:
SELECT ...
DATEPART(HOUR,TimeClicked) AS HourTimeClicked
....
May 20, 2013 at 2:16 am
Many thanks - this works perfectly
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply