Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to get last three month records from a table?

user-image
Question added by Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
Date Posted: 2013/08/25
Muhammed Sallout
by Muhammed Sallout , Technology Development Manager , GLORY TECHNOLOGY

SELECT * FROM `test` WHERE c5 >= DATE_SUB( CURDATE(), INTERVAL3 MONTH ) You can test this query online from the website, http://demo.phpmyadmin.net/STABLE/sql.php?db=a1&table=test&server=2&target=&token=e7563fb5c16bd1466#PMAURL-1:tbl_sql.php?db=a1&table=test&server=2&target=&token=e7563fb5c16bd1466

mirza habeeb
by mirza habeeb , Application Support & Database Developer , Via Technology

SELECT * FROM Member WHERE DATEPART(m, date_created)= DATEPART(m, DATEADD(m,-1, getdate()))AND DATEPART(y, date_created)= DATEPART(y, DATEADD(m,-1, getdate()))

George Dimitrov
by George Dimitrov , Unix System Administrator , ADVANCED.IO

table.date BETWEEN trunc((trunc(sysdate,'mm')-1),'mm') AND trunc(sysdate,'mm')-1 Or you can check TO_DATE function

SELECT*FROM Member WHERE DATEPART(m, date_created)= DATEPART(m, DATEADD(m,-1, getdate()))AND DATEPART(m, date_created)= DATEPART(y, DATEADD(m,-1, getdate()))

Sani Asnain Khan
by Sani Asnain Khan , Software Engineer , Fledge Innovation Solutions Pvt. Ltd

try it .
http://stackoverflow.com/questions//display-record-older-than-3-months-in-sql

Majed Al-jefri
by Majed Al-jefri , ERP and Database Assistant , KFUPM

where to_date(year || month,'YYYYMM')between add_months(trunc(sysdate,'MM'),-3)and trunc(sysdate)

Khawar Baig Mirza
by Khawar Baig Mirza , Asst. Executive (Programming) , Kohinoor Group

select * from rt_trans where updated >= trunc((select max(updated) from rt_trans)-interval '3' month)

Here updated is date type field

Aftab Alam
by Aftab Alam , IT Engineer , National Medical College

select *from table_name where to_date(to_char(columnName,'MM/DD/yyyy'),'MM/DD/yyyy')  between  fromDate and ToDate;

Mohammed Saeed Ahmed Mohammed Al-Sharabi
by Mohammed Saeed Ahmed Mohammed Al-Sharabi , مبرمج , فريق سمارت سوفت (Smart Soft Team)

SELECT * FROM table WHERE date >= DATE_SUB(CURDATE(), INTERVAL3 MONTHS) الفكرة في الشرط ان يكو تاريخ التسجيل اكبر او يساوي التاريخ الحالي ناقص ثلاثة اشهر date >= Date_now -3months

Ameen Ali Hassan Ali
by Ameen Ali Hassan Ali , Head of the Software Support Department , InventorTech Systems Co.

الامر يتعلق بالاستعلام عن بيانات بشرط انها ادخلت في الفتره من الان الاى ثلاثه شهور ماضيه

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.