M
Mike
If I have a date such as 4/2/2008, is there a way to go back a month such as
3/2/2008?
3/2/2008?
If I have a date such as 4/2/2008, is there a way to go back a month such as
3/2/2008?
Hans Kesting said:Mike explained :
DateTime dt = new DateTime(2008,4,2);
dt = dt.AddMonth(-1);
Hans Kesting
here is what I need.
I need to get todays date, then subtract the month and then pass only the
month to my database.
I have this;
DateTime dtToday = System.DateTime.Now;
//which gives me 4/2/2008
I then need to create a date of 3/2/2008 and only pass that month.
So if its 4/20/2008 I need to get 3/20/2008 and pass the 3.
If I do this
DateTime dt = DateTime.Parse(dtToday);
dt = dt.AddMonths(-1);
I'm getting the following error:
Error 24 The best overloaded method match for 'System.DateTime.Parse(string)'
has some invalid arguments
and
Error 25 Argument '1': cannot convert from 'System.DateTime' to 'string'