Click here to Skip to main content
15,606,838 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
how to convert the date-> 2012/12/03 11:11:04+22 to 2012/12/03 11:11:04 without splitting.I want to use (convert).
any solution?

You have to google first if you cant get it then ask here...

select [Date] = convert(char(10), getdate(), 111)

o/p: 2008/09/05
Share this answer
The DateTime class has a ToString method which accepts a format string as argument.
Using this you can format the date to any text representation you want.

See here for more details:[^]
Share this answer
Share this answer
My dear friend you can try this and send me feedbacks:

string day=System.DateTime.Now.Day;
string month=System.DateTime.Now.Month;
string Year=System.DateTime.Now.Year;
string hour=System.DateTime.Now.Hour;
string second=System.DateTime.Now.Second;
string minute=System.DateTime.Now.Minute;
Then you can play with them!:

string myTime=String.Format("{0}-{1}-{2}:{3}:{4}:{5}",year,month,day,hour,minute,second);
Another Example:
DateTime dat = new DateTime(2012, 1, 17, 9, 30, 0);
string city = "Chicago";
int temp = -16;
string output = String.Format("At {0} in {1}, the temperature was {2} degrees.",
                              dat, city, temp);
// The example displays the following output:
//    At 1/17/2012 9:30:00 AM in Chicago, the temperature was -16 degrees.

The result would be in myTime as you wish.

Good lock!
Share this answer
AT My storedprocedure i used-

           ,convert(datetime,@StartDt,103)  --It's avoid +22 in my date
Share this answer
What is +22 in 2012/12/03 11:11:04+22?
The code:

show the current date and time in correct format.
The result is like:

2012/12/03 11:11:04 AM
Share this answer
StackQ 3-Dec-12 3:55am    
i know about muchbetter.I have an application which reads sms from my handset.So here in my system it shows the date of sms,when i received it in above format,so i have to save this date in my database same but without +22,but i don't want to use splitting method.I want to convert it in the format (yyyy-mm-dd hh:mm:ss) only

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