Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to get last three month records from a table?

user-image
Question ajoutée par Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
Date de publication: 2013/08/25
Muhammed Sallout
par 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
par 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
par 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
par 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
par 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
par 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
par 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
par 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
par Ameen Ali Hassan Ali , Head of the Software Support Department , InventorTech Systems Co.

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

More Questions Like This