[Solved] How to split Date into Day/Month and Year parts using C# .Net

Last Reply on Feb 10, 2015 02:32 AM By Azim

Posted on Feb 10, 2015 02:28 AM

Hello I have a textbox, And I want to save the value of textbox into two different fields

For example

the value of texbox is

02/10/2015

and the fields are date and year.

 

So the result will be

date       year

02/10     2015

 

thanks

Posted on Feb 10, 2015 02:32 AM Modified on on Feb 10, 2015 03:44 AM

Refer this code snippet

C#

string date = "02/10/2015";
string[] splitedDate = date.Split('/');
//Save this in MonthDay field
string monthDay = string.Join("/", splitedDate[0], splitedDate[1]);
//Save this in Year field
string year = splitedDate[2];