string to datetime conversion ?
-
hi all, i have a string
string date= "09/02/27, 12:23:04"
the above string is in yy/mm/dd format, i want to convert it into a DateTime variable. When i convert i am getting the output as 9/2/2027, 12:23:04 PM which is wrong. I have tried the below code:DateTime dt = Convert.ToDateTime(date);
so i suspect its not the way, i think there are something to do with the Globalization namespace? any help will be much apreciated.....thanks..........:rose: -
hi all, i have a string
string date= "09/02/27, 12:23:04"
the above string is in yy/mm/dd format, i want to convert it into a DateTime variable. When i convert i am getting the output as 9/2/2027, 12:23:04 PM which is wrong. I have tried the below code:DateTime dt = Convert.ToDateTime(date);
so i suspect its not the way, i think there are something to do with the Globalization namespace? any help will be much apreciated.....thanks..........:rose:Yes.. Datetime objects acts according to your globalisation settings in yout machine/Application. The easiest way is to use Datetime.Tostring(yy/mm/dd) whenever you want ot display it :-D
Shyam.. My Blog dotnetscoups.blogspot.com
-
hi all, i have a string
string date= "09/02/27, 12:23:04"
the above string is in yy/mm/dd format, i want to convert it into a DateTime variable. When i convert i am getting the output as 9/2/2027, 12:23:04 PM which is wrong. I have tried the below code:DateTime dt = Convert.ToDateTime(date);
so i suspect its not the way, i think there are something to do with the Globalization namespace? any help will be much apreciated.....thanks..........:rose:DateTime.ParseExact() is what you need.
Cheers, Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends. - Josh Gray.
-
DateTime.ParseExact() is what you need.
Cheers, Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends. - Josh Gray.
i will be gratefull if u can provide me a sample code, what are the values inside parseExact()??
-
i will be gratefull if u can provide me a sample code, what are the values inside parseExact()??