Convert.ToDateTime Problem
-
Hi all, Yesterday i had the problem when i tried to convert a string to DateTime I wanted to do the following:
string _appDate=_CurrentSelectedDate.Date.ToString("yyyy/MM/dd"); string _fromDateTime = _appDate+" "+startTime; string _endDateTime = _appDate+" "+endTime; FromTime = Convert.ToDateTime(_fromDateTime); ToTime = Convert.ToDateTime(_endDateTime);
Now in this example the value of_appDate
is "2006/11/07" the value of_startTime
is "4:00 PM" the value of_endTime
is "5:00 PM" That makes the value of_fromDateTime
= "2006/11/07 4:00 PM" and the value of_endDateTime
= "2006/11/07 5:00 PM" I checked and it is... Now when i try to Convert.ToDateTime for theFromDate
and theToDate
The value ofFromTime
is 7/11/2006 and value ofToTime
is 7/11/2006 :confused: on the other computer the values are correct but not on mine... The regional settings are the same... Please help"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
-
Hi all, Yesterday i had the problem when i tried to convert a string to DateTime I wanted to do the following:
string _appDate=_CurrentSelectedDate.Date.ToString("yyyy/MM/dd"); string _fromDateTime = _appDate+" "+startTime; string _endDateTime = _appDate+" "+endTime; FromTime = Convert.ToDateTime(_fromDateTime); ToTime = Convert.ToDateTime(_endDateTime);
Now in this example the value of_appDate
is "2006/11/07" the value of_startTime
is "4:00 PM" the value of_endTime
is "5:00 PM" That makes the value of_fromDateTime
= "2006/11/07 4:00 PM" and the value of_endDateTime
= "2006/11/07 5:00 PM" I checked and it is... Now when i try to Convert.ToDateTime for theFromDate
and theToDate
The value ofFromTime
is 7/11/2006 and value ofToTime
is 7/11/2006 :confused: on the other computer the values are correct but not on mine... The regional settings are the same... Please help"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
-
What exactly is the problem? Arent you getting the time values? Mubashir
Every job is a self portrait of the person who did it.
Oh no sorry... I only get the date back like this... "11/7/2006" I want it to work like it does on the other PC "2006/07/11 4:00:00 PM" It worked on my PC too but i haven't changed the regional settings, i haven't altered the code of this segment...only now to try and fix it. I don't know... :((
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
-
What exactly is the problem? Arent you getting the time values? Mubashir
Every job is a self portrait of the person who did it.
Hi, This problem has a whole new twist.... Everywhere in my code where i use the
Covert.ToDateTime
i have the same problem... it doesn't show me the time any more... only the date but not even in the yyyy/MM/dd format, now it is in the dd/MM/yyyy format. Do you think that if i built the installer and and installed it onto another computer that it would work... I mean there is nothing wrong with the code, it's just weird... i checked the regional settings again => same as the other computer... before i build the installer, and find a pc to install it on... do you think it would work correctly on another PC if it's acting weird on mine?"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
-
What exactly is the problem? Arent you getting the time values? Mubashir
Every job is a self portrait of the person who did it.
Ha, it works.... there must be something wrong on my pc... some setting or something... Thank you for your time... I think i need to reinstall my PC. :doh: But, this at least will speed up my system a little... :-)
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
-
Hi all, Yesterday i had the problem when i tried to convert a string to DateTime I wanted to do the following:
string _appDate=_CurrentSelectedDate.Date.ToString("yyyy/MM/dd"); string _fromDateTime = _appDate+" "+startTime; string _endDateTime = _appDate+" "+endTime; FromTime = Convert.ToDateTime(_fromDateTime); ToTime = Convert.ToDateTime(_endDateTime);
Now in this example the value of_appDate
is "2006/11/07" the value of_startTime
is "4:00 PM" the value of_endTime
is "5:00 PM" That makes the value of_fromDateTime
= "2006/11/07 4:00 PM" and the value of_endDateTime
= "2006/11/07 5:00 PM" I checked and it is... Now when i try to Convert.ToDateTime for theFromDate
and theToDate
The value ofFromTime
is 7/11/2006 and value ofToTime
is 7/11/2006 :confused: on the other computer the values are correct but not on mine... The regional settings are the same... Please help"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison