Showing posts with label DateTime. Show all posts
Showing posts with label DateTime. Show all posts

Wednesday, May 1, 2013

C# DateTimePicker CustomFormat Month and Year

Using DateTimePicker to select month and year only.
//to configure datetimepicker for month and year.

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MMM-yyyy";
dateTimePicker1.ShowUpDown = true;

//to get value of the datetimepicker.
dateTimePicker1.Value.ToString("yyyy-MM");


Additional Reading at :
  1. MSDN DateTimePicker
  2. MSDN CustomFormat
  3. MSDN ShowUpDown

Wednesday, December 19, 2012

C# Custom Value from DateTimePicker

Custom value from datetimepicker as below:
 
string date = DateTimePicker1.Value.ToString("yyyy-MM-dd");

C# DateTime Custom String Method

Sample Code as bellow:
DateTime DT = DateTime.ParseExact("20121207015640","yyyyMMddHHmmss",null);  
For more info MSDN DateTime.ParseExact