当前年份和当前年份之间的mysql + 6个月

时间:2015-04-26 17:33:51

标签: mysql

我需要查询当前年份与当前年份+ 6个月之间的条件日期

SELECT VOZ.prez_vozac,VOZ.ime_vozac,LOD.naz_lok,LDO.naz_lok,V.datum
    FROM voznja AS V
    INNER JOIN vozac AS VOZ ON V.sif_vozac = VOZ.sif_vozac
    INNER JOIN lokacija AS LOD ON V.sif_lok_od = LOD.sif_lok
    INNER JOIN lokacija AS LDO ON V.sif_lok_do = LDO.sif_lok
    INNER JOIN vozilo AS VOZI ON V.regbr = VOZI.regbr
    INNER JOIN teret AS T ON V.sif_teret = T.sif_teret
    WHERE T.tezina <= 5 AND V.datum BETWEEN ***CURENT YEAR*** AND ***CURRENT YEAR + 6 MONTHS ***

1 个答案:

答案 0 :(得分:0)

假设你的意思是现在的日期和现在的六个月......

   SELECT VOZ.prez_vozac,VOZ.ime_vozac,LOD.naz_lok,LDO.naz_lok,V.datum
    FROM voznja AS V
    INNER JOIN vozac AS VOZ ON V.sif_vozac = VOZ.sif_vozac
    INNER JOIN lokacija AS LOD ON V.sif_lok_od = LOD.sif_lok
    INNER JOIN lokacija AS LDO ON V.sif_lok_do = LDO.sif_lok
    INNER JOIN vozilo AS VOZI ON V.regbr = VOZI.regbr
    INNER JOIN teret AS T ON V.sif_teret = T.sif_teret
    WHERE T.tezina <= 5 AND V.datum BETWEEN CURDATE() 
AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH)