Link to home
Start Free TrialLog in
Avatar of sbornstein2
sbornstein2

asked on

C# DateTime from Month and Year

Hello all,

I have the following,  Month Abbreviation such as Jan and Year such as 2015 in a string "Jan 2015".   I need to take that and get the 1st and last day of that month into two datetime variables.  

I got the month abbreviation using:

DateTimeFormatInfo mfi = new DateTimeFormatInfo();
mfi.GetAbbreviatedMonthName(1) as an example.

I guess I need to parse the numeric and string portion to do this?   So in the above case Jan 2015 I would want two datetime variables as:

DateTime startDate = 1/12015
DateTime endDate = 1/31/2015
SOLUTION
Avatar of FarWest
FarWest

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sbornstein2
sbornstein2

ASKER

ah very clever it is.   Did not know it could parse a month and year like that.  Thanks
You are welcome!
.Net is magic.

/gustav