I have 2 strings, "12/28/2005" and "16:44:54". I need to conatenate them and
convert them to datetime format so I can assign them to a datetime field in a
datarow. The time is now being converted to the date "12/28/2005". and I
don't know how to concatenate them since "+" won't work after I convert them.
Thanks, Alpha
if (result == "00")
{
char[] separator = {','};
char[] intSep = {'.'};
string lastDate, lastTime, lastMilleage;
DataRow drVeh = dsVehicle.Tables["VehDetail"].Rows[VListing.CurrentRowIndex];
DialogResult msgRet;
string[] replySeparated = ATSReply.Split(separator);
lastDate = replySeparated[2];
lastTime = replySeparated[3];
lastMilleage = replySeparated[4];
lastMilleage = lastMilleage.Substring(0, lastMilleage.Length - 3);
string[] intLastMilleage = lastMilleage.Split(intSep);
msgRet = MessageBox.Show("Would you like to update the vehicle odometer to
" + lastMilleage +
" and the last odometer read date to " + lastDate + " and the read time to
" +
lastTime, "Live Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if(msgRet == DialogResult.Yes)
{
DateTime DatelastDate = Convert.ToDateTime(lastDate);
DateTime TimeLastTime = Convert.ToDateTime(lastTime);
// DateTime lastDateTime = DatelastDate + TimeLastTime;
drVeh["LastOdometerDate"] = DatelastDate;
drVeh["LastOdometerReading"] = Convert.ToInt32(intLastMilleage[0]);
drVeh.EndEdit();
}
} 3 1441
Hi,
Sorry for the re-post ,check the DateTimeFormatInfo class for build format
strings
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com... I have 2 strings, "12/28/2005" and "16:44:54". I need to conatenate them and convert them to datetime format so I can assign them to a datetime field in a datarow. The time is now being converted to the date "12/28/2005". and I don't know how to concatenate them since "+" won't work after I convert them. Thanks, Alpha
if (result == "00") { char[] separator = {','}; char[] intSep = {'.'}; string lastDate, lastTime, lastMilleage; DataRow drVeh = dsVehicle.Tables["VehDetail"].Rows[VListing.CurrentRowIndex]; DialogResult msgRet;
string[] replySeparated = ATSReply.Split(separator); lastDate = replySeparated[2]; lastTime = replySeparated[3]; lastMilleage = replySeparated[4]; lastMilleage = lastMilleage.Substring(0, lastMilleage.Length - 3); string[] intLastMilleage = lastMilleage.Split(intSep);
msgRet = MessageBox.Show("Would you like to update the vehicle odometer to " + lastMilleage + " and the last odometer read date to " + lastDate + " and the read time to " + lastTime, "Live Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if(msgRet == DialogResult.Yes) { DateTime DatelastDate = Convert.ToDateTime(lastDate); DateTime TimeLastTime = Convert.ToDateTime(lastTime); // DateTime lastDateTime = DatelastDate + TimeLastTime;
drVeh["LastOdometerDate"] = DatelastDate; drVeh["LastOdometerReading"] = Convert.ToInt32(intLastMilleage[0]); drVeh.EndEdit();
}
}
Hi,
You could use DateTime.ParseExact( date_String + " " + time_String,
"MM/dd/yyyy HH:mm:ss, CultureInfo.InvariantCulture.DateTimeFormat );
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com... I have 2 strings, "12/28/2005" and "16:44:54". I need to conatenate them and convert them to datetime format so I can assign them to a datetime field in a datarow. The time is now being converted to the date "12/28/2005". and I don't know how to concatenate them since "+" won't work after I convert them. Thanks, Alpha
if (result == "00") { char[] separator = {','}; char[] intSep = {'.'}; string lastDate, lastTime, lastMilleage; DataRow drVeh = dsVehicle.Tables["VehDetail"].Rows[VListing.CurrentRowIndex]; DialogResult msgRet;
string[] replySeparated = ATSReply.Split(separator); lastDate = replySeparated[2]; lastTime = replySeparated[3]; lastMilleage = replySeparated[4]; lastMilleage = lastMilleage.Substring(0, lastMilleage.Length - 3); string[] intLastMilleage = lastMilleage.Split(intSep);
msgRet = MessageBox.Show("Would you like to update the vehicle odometer to " + lastMilleage + " and the last odometer read date to " + lastDate + " and the read time to " + lastTime, "Live Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if(msgRet == DialogResult.Yes) { DateTime DatelastDate = Convert.ToDateTime(lastDate); DateTime TimeLastTime = Convert.ToDateTime(lastTime); // DateTime lastDateTime = DatelastDate + TimeLastTime;
drVeh["LastOdometerDate"] = DatelastDate; drVeh["LastOdometerReading"] = Convert.ToInt32(intLastMilleage[0]); drVeh.EndEdit();
}
}
Thank you Ignacio. That worked out great!
Alpha
"Ignacio Machin ( .NET/ C# MVP )" wrote: Hi,
You could use DateTime.ParseExact( date_String + " " + time_String, "MM/dd/yyyy HH:mm:ss, CultureInfo.InvariantCulture.DateTimeFormat );
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:29**********************************@microsof t.com...I have 2 strings, "12/28/2005" and "16:44:54". I need to conatenate them and convert them to datetime format so I can assign them to a datetime field in a datarow. The time is now being converted to the date "12/28/2005". and I don't know how to concatenate them since "+" won't work after I convert them. Thanks, Alpha
if (result == "00") { char[] separator = {','}; char[] intSep = {'.'}; string lastDate, lastTime, lastMilleage; DataRow drVeh = dsVehicle.Tables["VehDetail"].Rows[VListing.CurrentRowIndex]; DialogResult msgRet;
string[] replySeparated = ATSReply.Split(separator); lastDate = replySeparated[2]; lastTime = replySeparated[3]; lastMilleage = replySeparated[4]; lastMilleage = lastMilleage.Substring(0, lastMilleage.Length - 3); string[] intLastMilleage = lastMilleage.Split(intSep);
msgRet = MessageBox.Show("Would you like to update the vehicle odometer to " + lastMilleage + " and the last odometer read date to " + lastDate + " and the read time to " + lastTime, "Live Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if(msgRet == DialogResult.Yes) { DateTime DatelastDate = Convert.ToDateTime(lastDate); DateTime TimeLastTime = Convert.ToDateTime(lastTime); // DateTime lastDateTime = DatelastDate + TimeLastTime;
drVeh["LastOdometerDate"] = DatelastDate; drVeh["LastOdometerReading"] = Convert.ToInt32(intLastMilleage[0]); drVeh.EndEdit();
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: php newbie |
last post by:
Hello,
I am trying to insert some date values into a table. I am using ODBC
prepared statements to (potentially) improve performance. The
statement syntax I am using is this:
INSERT INTO...
|
by: Kim Hellan |
last post by:
I have a simple string in the format "DD-MM-YY hh:mm:ss", that I need to
convert to a DateTime value.
I know this is a standard problem, but please don't just link to all the
MSDN pages regarding...
|
by: NateM |
last post by:
How do I convert any given date into a milliseconds value that
represents the number of milliseconds that have passed since January 1,
1970 00:00:00.000 GMT?
Is there an easy way to do this like...
|
by: Dixie |
last post by:
I am trying to calculate the number of workdays between two dates with
regards to holidays as well. I have used Arvin Meyer's code on the Access
Web, but as I am in Australia and my date format is...
|
by: Alok yadav |
last post by:
i am using a webservice in which a method is serach. i use this method
which accept a argument of date type in dd/MM/yyyy formate. i have a
textbox which accept the date from the user, when i...
|
by: gs |
last post by:
let say I have to deal with various date format and I am give format string
from one of the following
dd/mm/yyyy
mm/dd/yyyy
dd/mmm/yyyy
mmm/dd/yyyy
dd/mm/yy
mm/dd/yy
dd/mmm/yy
mmm/dd/yy
|
by: helpwithcode |
last post by:
Hi people,
I am just learning java.I have been creating a project which involves JDBC Connectivity.I find that the statements,
String string_dob=text_dob.getText();
//Converting string to...
|
by: rob41 |
last post by:
I'm in the process of converting numerous queries from access 07 to sql server 05 to improve runtime performance. Below is a sample of code and the error I'm getting.
INSERT INTO
( , , ,...
|
by: matheussousuke |
last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails.
The goal is: Make it send the email with the URL...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |