| required date month year query [message #643266] |
Fri, 02 October 2015 04:15  |
 |
sudheerips
Messages: 7 Registered: September 2015 Location: visakhapatnam
|
Junior Member |
|
|
hi,
I have a employees table.
My requirement is
who are joined in sep/1999.I want like this(sep/1999).
if i try to get that values i am getting like this(23/sep/1999) date,month and year also.
but month and year are not getting.
please tell me
[Updated on: Fri, 02 October 2015 04:18] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
| Re: required date month year query [message #643291 is a reply to message #643273] |
Fri, 02 October 2015 14:03   |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
if you want the number of people who joined in september 1999 then
select to_char(hiredate,'Mon/yyyy') month,count(*)
from emps
where hiredate between to_date('09011999','mmddyyyy') and last_day(to_date('09011999','mmddyyyy'));
If it is other than that, use a similar idea
|
|
|
|
|
|
|
|
|
|
| Re: required date month year query [message #643484 is a reply to message #643460] |
Thu, 08 October 2015 07:46   |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
sudheerips wrote on Thu, 08 October 2015 01:13query not working
shows error
ORA-00937: not a single-group group function
i attached the image file.
please see
Sorry
select to_char(hiredate,'Mon/yyyy') month,count(*)
from emps
where hiredate between to_date('09011999','mmddyyyy') and last_day(to_date('09011999','mmddyyyy'))
group by to_char(hiredate,'Mon/yyyy');
|
|
|
|
| Re: required date month year query [message #643486 is a reply to message #643484] |
Thu, 08 October 2015 08:00   |
cookiemonster
Messages: 13975 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
If hiredate can have times other than midnight then that should be:
where hiredate >= to_date('09011999','mmddyyyy')
and hiredate < last_day(to_date('09011999','mmddyyyy')) + 1
Otherwise anything after midnight on the last day will be ignored.
|
|
|
|
|
|