swf Posted May 19, 2005 Report Share Posted May 19, 2005 datubaazee ir tabula, no 3. laukiem |___id___|__datefrom__|__dateto__| | | | | probza taada, ka datefrom and dateto (abi varchar) ir salikti tipa taadi: datefrom: 24/09/05 dateto: 31/09/05 vajadzeetu baigi paliidziibu kaa vareetu vinjus paarveidot aatri par tipa: datefrom: 2005-09-24 dateto: 2005-09-31 any ideas? :huh: Link to comment Share on other sites More sharing options...
bubu Posted May 19, 2005 Report Share Posted May 19, 2005 SELECT DATE_FORMAT(STR_TO_DATE(datefrom,'%d/%m/%y'), '%Y-%m-%d') as datefrom FROM tabula (tas pats ar otro kolonnu) Diemžēl STR_TO_DATE() ir tikai sākot no MySQL 4.1.1. Ja kas, sliktākā gadījumā var jau php pusē apstrādāt to tekstu, ko dabū no DB. Link to comment Share on other sites More sharing options...
swf Posted May 19, 2005 Author Report Share Posted May 19, 2005 O! viss aizgaaja, paldies! varbuut pie reizes vari pateikt kaa pie shitaa skripta update funkciju pielikt lai nomainiitu to visu par Y-m-d? (im newbie :huh: ) Link to comment Share on other sites More sharing options...
bubu Posted May 19, 2005 Report Share Posted May 19, 2005 Nu to tev pašam būtu vajadzējis izdomāt, paskatoties MySQL manuālī UPDATE sintaksi, ja jau ņemies ar šādām lietām: UPDATE tabula SET datefrom = DATE_FORMAT(STR_TO_DATE(datefrom,'%d/%m/%y'), '%Y-%m-%d') Pie tam, daudz labāk būtu, ja nomainītu kolonnas tipu uz datuma tipu, nevis varcharu atstātu. Link to comment Share on other sites More sharing options...
swf Posted May 19, 2005 Author Report Share Posted May 19, 2005 viss ok thanks Link to comment Share on other sites More sharing options...
Recommended Posts