Home > OS >  How to display date seven days before the supposed date "tarikh_mulali" using mySQL?
How to display date seven days before the supposed date "tarikh_mulali" using mySQL?

Time:05-26

MySQL below is given. How to set condition to display date seven days before the supposed date "tarikh_mulali"

 $query = "SELECT * FROM ((maklumat_pemohon INNER JOIN maklumat_tawaran ON 
 maklumat_pemohon.noic_pemohon = maklumat_tawaran.noic_pemohon) INNER JOIN 
 maklumat_status ON maklumat_pemohon.noic_pemohon = maklumat_status.noic_pemohon) WHERE 
 (tarikh_mulali >= DAY(DATE_SUB(CURRENT_DATE,INTERVAL 7 DAY)))  AND status_lapordiri = 
 'MELAPOR DIRI'";

CodePudding user response:

If I not misunderstand, you asking the way to display earlier 7 days before tarikh_mulali?

SELECT tarikh_mulali - INTERVAL 7 DAY from ......

CodePudding user response:

You can use SUBDATE() SUBDATE(CURRENT_DATE,7) will display 7 days before current date. For future date, use SUBDATE(CURRENT_DATE,-7)

  • Related