o2T Posted September 27, 2004 Report Share Posted September 27, 2004 sasodiits,nesanaak, man vajag no tabuliisha atlasiit tos ierakstus,kuriem exp_date pienaaks peec 20 vai mazaak dienaam. help? :ph34r: Link to comment Share on other sites More sharing options...
hmnc Posted September 27, 2004 Report Share Posted September 27, 2004 (edited) varbūt ir kāds ne tik garš pieraksts, bet šis man strādā: $exp_date = date ('Y-m-d H:i:s', mktime(date('H'),date('i'),date('s'), date('m'), date('d')-20, date('Y'))); mysql_query ("DELETE FROM _table_ WHERE _date_<'$exp_date'"); attiecīgi tabulas lauciņam _date_ jābūt DATETIME formātam. ja nav, tad maini date() parametru. UPDATE sorr. nepamanīju ka vajag atlasīt. :) loģiski izmantojam SELECT, DELETE vietā. gan jau, ka neesi pirmo reizi tankā - izdomāsi :) Edited September 27, 2004 by hmnc Link to comment Share on other sites More sharing options...
cuuu Posted September 28, 2004 Report Share Posted September 28, 2004 (edited) tīri dabiski ir datumus glabāt unix timestamp formātā. tad, pieprasījums iznāk gauži vienkāršs - $limit = time() + 86400 * 20; $sql = "select ... from the_table where exp_date < $limit"; Edited September 28, 2004 by cuuu Link to comment Share on other sites More sharing options...
рпр Posted September 28, 2004 Report Share Posted September 28, 2004 (edited) tiiri ar sql: select date_format(exp_date, '%d.%m.%Y') from tabula where (to_days(now())-TO_DAYS(exp_date))<=20; select date_format(exp_date, '%d.%m.%Y') from tabula where (INTERVAL "20" DAY + exp_date)>=now() ; un veel var ar timestampiem paspeeleeties... Edited September 28, 2004 by рпр Link to comment Share on other sites More sharing options...
Recommended Posts