Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello frens i have the same question, i now broke the date into month,day,year and all of them are in string, now what i wanted to do is concatenate it so that the format looks like 11/4/2011 but when i concatenated, i could not append / with string? how to perform such task please help
with regards bishnu karki
Posted
Comments
[no name] 3-Nov-11 5:28am    
How are you concatenating? can you show your code so that it is easy to understand your problem?

Not sure why you are splitting your Date into Month, Day and Year and then again want to concatenate it.

Instead use below syntax.
C#
string myDate = System.DateTime.Now.ToString("MM/dd/yyyy");
 
Share this answer
 
what is the problem when all are in string form u can simply do as:
C#
string a = "12";
        string b = "12";
        string c= "12";
        string d = a+"/"+b+"/"+c;

string d will have complete date in string form only
 
Share this answer
 
v2
Assuming you have 3 dropdown for date, you can try something like :

C#
int day = 0;
int month = 0;
int year = 0;
day = Convert.ToInt32(dropdownday.SelectedValue.ToString());
month = Convert.ToInt32(dropdownMonth.SelectedValue.ToString());
year = Convert.ToInt32(dropdownYear.SelectedValue.ToString());

System.DateTime newdate = new System.DateTime(year, month, day);
newdate.ToString("d");
//newdate can be passed as datetime parameter;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900