where clause for previous month date [message #410919] |
Wed, 01 July 2009 01:11  |
vivek_rol
Messages: 65 Registered: February 2009
|
Member |
|
|
hi all,
1 date of every month i run one job,
this job populates data in text file
this job populates the data of employee which is enroll between 22 to 30 or 31 of previous month
so how sholud i write 'where' clause to populate enroll employee of previous month 22 to 31 0r 30,
this job runs on 1 st of every month
please guide
|
|
|
|
|
|
|
|
Re: where clause for previous month date [message #411120 is a reply to message #411115] |
Thu, 02 July 2009 01:46   |
 |
Michel Cadot
Messages: 68767 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
We all know how do it, we gave all the information to do it.
Please read OraFAQ Forum Guide and follow it.
Quote: | When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.
|
"How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Regards
Michel
|
|
|
Re: where clause for previous month date [message #411126 is a reply to message #411115] |
Thu, 02 July 2009 01:53   |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
ds285269 wrote on Thu, 02 July 2009 08:06 | Hi,
Try with below code.
select * from emp
where
hiredate between add_months(to_date(sysdate),-1)+21 and last_day(add_months(TO_DATE(sysdate),-1))
|
Why would you convert sysdate to a date? It requires Oracle to first do an implicit to_char.
|
|
|
|
|