How do I get a dattime format in C# that will look like this:
2011-09-01 00:00:00:000
This works
DateTime saveNow = DateTime.Now;
string test = String.Format("{0:yyyy-MM-01 00:00:00:000}", saveNow);
Now I want to know this. How would I subtract one month from the current month?
It T-SQL it would look like this
[IMG]http://i67.photobucket.com/albums/h292/Athono/THIS-1.png[/IMG]
How would it be done in C#?
trying the addmonth method with a negative one did not work
[IMG]http://i67.photobucket.com/albums/h292/Athono/thisdidnotwork.png[/IMG]

Dorababu MekaPosted Sep 22, 2011, 4:18 AM
VulpesPosted Sep 22, 2011, 4:11 AM
DateTime dt = DateTime.Now.AddMonths(-1);
Console.WriteLine("{0:yyyy-MM-dd 00:00:00:000}", dt);
producing the expected output of :
2011-08-22 00:00:00:000
Mayur GujrathiPosted Sep 22, 2011, 4:09 AM