sitijaafar
asked on
Problem with select statement that contains datetime type
Hi experts,
How to select the data where the condition 'yyyy-mm-%' and 'yyyy-%'
select count=count(*) from audit_trail where access_time like '2009-11-%'
and
select count=count(*) from audit_trail where access_time like '2009-%'
This statement fine in mysql but not ms sql.
The data is like below
user access_time
------- -----------------------
zazimi 2009-11-26 15:19:51.717
qaisara 2009-11-26 15:20:24.747
How to select the data where the condition 'yyyy-mm-%' and 'yyyy-%'
select count=count(*) from audit_trail where access_time like '2009-11-%'
and
select count=count(*) from audit_trail where access_time like '2009-%'
This statement fine in mysql but not ms sql.
The data is like below
user access_time
------- -----------------------
zazimi 2009-11-26 15:19:51.717
qaisara 2009-11-26 15:20:24.747
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
(^_^)
select count=count(*) from audit_trail where year(access_time) =2009 and month(access_time) =11
select count=count(*) from audit_trail where year(access_time) =2009