//get a string of last month public static string GetCurrentYearLastMonthStr() { DateTime dt = DateTime.Now; dt = dt.AddMonths(-1); return(UtilAll.DigitsCreate(dt.Year, 4) + "-" + Catalog.GetString(dt.ToString("MMMM"))); }
//records date & time, useful to backup database without having strange chars on filename public static string ToFile(DateTime dt) { return(UtilAll.DigitsCreate(dt.Year, 4) + "-" + UtilAll.DigitsCreate(dt.Month, 2) + "-" + UtilAll.DigitsCreate(dt.Day, 2) + "_" + UtilAll.DigitsCreate(dt.Hour, 2) + "-" + UtilAll.DigitsCreate(dt.Minute, 2) + "-" + UtilAll.DigitsCreate(dt.Second, 2)); }
//comes datetime //insert in sql like YYYY-MM-DD (with always all digits) //we use Year, Month and Day for not having any problem with locale public static string ToSql(DateTime dt) { return(UtilAll.DigitsCreate(dt.Year, 4) + "-" + UtilAll.DigitsCreate(dt.Month, 2) + "-" + UtilAll.DigitsCreate(dt.Day, 2)); }