Click here to Skip to main content
16,018,394 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have one string which i am retrieving from database which is displaying like
ex-2012-04-02T12:04:47.9010868+10:00

Now ,I want to display it like 2012-04-02 T 12:04:47.9010868 + 10:00

Its very urgent pls suggest some solutions.

Regards
Posted
Comments
Archana K 6-May-13 7:10am    
Use split function.......

Try this
VB
"2012-04-02T12:04:47.9010868+10:00".Tostring().Replace("T"," T ").Replace("+"," + ")

Happy Coding!
:)
 
Share this answer
 
Comments
richa11 6-May-13 7:49am    
Thanks Aarti..it worked..
Aarti Meswania 6-May-13 7:50am    
Welcome!
Glad to help you! :)
If you are retrieving it from the database as a string (i.e. it is stored as a string rather than a DateTime field) then you have no choice but to break it into it's constituent parts sith Substring and reassemble it with the spaces where you want. But it would be a lot better to store it in a DateTime field instead as these are a lot more flexible.

If you store it as a DateTime, then all you need to do is specify the exact format you want when you convert it to a string for display: Formatting a DateTime for display - format string description[^] will help.
 
Share this answer
 
Comments
richa11 6-May-13 7:17am    
yes I am storing it as DateTime
OriginalGriff 6-May-13 7:39am    
Then retrieve it into a DateTime in your VB code and supply a format string that does exactly what you want - the tip I referred to should provide all you need.

I can't be any more precise without seeing the relevant code fragment! :laugh:
richa11 6-May-13 7:49am    
I tried but it was not working
OriginalGriff 6-May-13 8:25am    
What did you try?

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