Ich hatte mal wieder das Problem DateTimes in Datenbanken speichern zu müssen.
Damit ich es nicht wieder vergesse, hier eine kleine mini-übersicht 🙂
1 2 3 4 5 6 7 | string datum; // Für MS Visual Foxpro bzw. DBF datum = "{^" + DateTime.Now.ToString("yyyy/MM/dd") + "}"; // Für MySQL datum = DateTime.Now.ToString("yyyy:MM:dd hh:mm:ss"); DB.sql("INSERT INTO tabelle SET datumfeld='"+datum+"' WHERE id=1"); |
Login