String Format for DateTime in C#

String Format for DateTime in C# To Custom DateTime Format There are following custom format specifiers is available y (year), M (month), d (day), h (hour 12), H (hour 24), m (minute), s (second), f (second fraction), F (second fraction, trailing zeroes are trimmed), t (P.M or A.M) and z (time zone). // create date time 2008-03-09 16:05:07.123 DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123); String.Format("{0:y yy yyy yyyy}", dt); // "9 09 009 2009" year String.Format("{0:M MM MM...
More

SQL datetime format

The following conversion options are available for sql datetime format : select convert(char, getdate(), 100) -- mon dd yyyy hh:mmAM (or PM) -- Oct  2 2008 11:01AM select convert(char, getdate(), 101) -- mm/dd/yyyy -- 10/02/2008 select convert(char, getdate(), 102) -- yyyy.mm.dd -- 2008.10.02 select convert(char, getdate(), 103) -- dd/mm/yyyy select convert(char, getdate(), 104) -- dd.mm.yyyy select convert(char, getdate(), 105) -- dd-mm-yyyy select convert(char, getdate(), 106) -- dd ...
More