473,569 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help with converting a Date and a Time string after concate

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.Table s["VehDetail"].Rows[VListing.Curren tRowIndex];
DialogResult msgRet;

string[] replySeparated = ATSReply.Split( separator);
lastDate = replySeparated[2];
lastTime = replySeparated[3];
lastMilleage = replySeparated[4];
lastMilleage = lastMilleage.Su bstring(0, lastMilleage.Le ngth - 3);
string[] intLastMilleage = lastMilleage.Sp lit(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", MessageBoxButto ns.YesNo, MessageBoxIcon. Question);
if(msgRet == DialogResult.Ye s)
{
DateTime DatelastDate = Convert.ToDateT ime(lastDate);
DateTime TimeLastTime = Convert.ToDateT ime(lastTime);
// DateTime lastDateTime = DatelastDate + TimeLastTime;

drVeh["LastOdometerDa te"] = DatelastDate;
drVeh["LastOdometerRe ading"] = Convert.ToInt32 (intLastMilleag e[0]);
drVeh.EndEdit() ;

}

}
Dec 29 '05 #1
3 1452
Hi,
Sorry for the re-post ,check the DateTimeFormatI nfo class for build format
strings
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Alpha" <Al***@discussi ons.microsoft.c om> wrote in message
news:29******** *************** ***********@mic rosoft.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.Table s["VehDetail"].Rows[VListing.Curren tRowIndex];
DialogResult msgRet;

string[] replySeparated = ATSReply.Split( separator);
lastDate = replySeparated[2];
lastTime = replySeparated[3];
lastMilleage = replySeparated[4];
lastMilleage = lastMilleage.Su bstring(0, lastMilleage.Le ngth - 3);
string[] intLastMilleage = lastMilleage.Sp lit(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", MessageBoxButto ns.YesNo,
MessageBoxIcon. Question);
if(msgRet == DialogResult.Ye s)
{
DateTime DatelastDate = Convert.ToDateT ime(lastDate);
DateTime TimeLastTime = Convert.ToDateT ime(lastTime);
// DateTime lastDateTime = DatelastDate + TimeLastTime;

drVeh["LastOdometerDa te"] = DatelastDate;
drVeh["LastOdometerRe ading"] = Convert.ToInt32 (intLastMilleag e[0]);
drVeh.EndEdit() ;

}

}

Dec 29 '05 #2
Hi,

You could use DateTime.ParseE xact( date_String + " " + time_String,
"MM/dd/yyyy HH:mm:ss, CultureInfo.Inv ariantCulture.D ateTimeFormat );
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Alpha" <Al***@discussi ons.microsoft.c om> wrote in message
news:29******** *************** ***********@mic rosoft.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.Table s["VehDetail"].Rows[VListing.Curren tRowIndex];
DialogResult msgRet;

string[] replySeparated = ATSReply.Split( separator);
lastDate = replySeparated[2];
lastTime = replySeparated[3];
lastMilleage = replySeparated[4];
lastMilleage = lastMilleage.Su bstring(0, lastMilleage.Le ngth - 3);
string[] intLastMilleage = lastMilleage.Sp lit(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", MessageBoxButto ns.YesNo,
MessageBoxIcon. Question);
if(msgRet == DialogResult.Ye s)
{
DateTime DatelastDate = Convert.ToDateT ime(lastDate);
DateTime TimeLastTime = Convert.ToDateT ime(lastTime);
// DateTime lastDateTime = DatelastDate + TimeLastTime;

drVeh["LastOdometerDa te"] = DatelastDate;
drVeh["LastOdometerRe ading"] = Convert.ToInt32 (intLastMilleag e[0]);
drVeh.EndEdit() ;

}

}

Dec 29 '05 #3
Thank you Ignacio. That worked out great!

Alpha

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

You could use DateTime.ParseE xact( date_String + " " + time_String,
"MM/dd/yyyy HH:mm:ss, CultureInfo.Inv ariantCulture.D ateTimeFormat );
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Alpha" <Al***@discussi ons.microsoft.c om> wrote in message
news:29******** *************** ***********@mic rosoft.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.Table s["VehDetail"].Rows[VListing.Curren tRowIndex];
DialogResult msgRet;

string[] replySeparated = ATSReply.Split( separator);
lastDate = replySeparated[2];
lastTime = replySeparated[3];
lastMilleage = replySeparated[4];
lastMilleage = lastMilleage.Su bstring(0, lastMilleage.Le ngth - 3);
string[] intLastMilleage = lastMilleage.Sp lit(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", MessageBoxButto ns.YesNo,
MessageBoxIcon. Question);
if(msgRet == DialogResult.Ye s)
{
DateTime DatelastDate = Convert.ToDateT ime(lastDate);
DateTime TimeLastTime = Convert.ToDateT ime(lastTime);
// DateTime lastDateTime = DatelastDate + TimeLastTime;

drVeh["LastOdometerDa te"] = DatelastDate;
drVeh["LastOdometerRe ading"] = Convert.ToInt32 (intLastMilleag e[0]);
drVeh.EndEdit() ;

}

}


Dec 29 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1964
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 date_tests (date_col) VALUES ( CONVERT(DATETIME, ?, 121) ) The table is defined as "CREATE TABLE date_tests (date_col DATETIME)". Then, I call this...
10
15533
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 Parse() and ParseExact(). I've been there and read all the information about using IFormatProviders, DateTimeStyles, CultureInfo....... Bottom...
3
12419
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 Date in java? Thanks, Nate
12
2425
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 dd/mm/yyyy, I have found that the dates I put in my holidays table are reversed into American dates. So, the wrong holiday dates are subtracted...
9
12936
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 convert textbox data into Datatime formate it converted into MM/dd/yyyy formate, but i have a requirement in dd/MM/yyyy formate. please help me, i am...
29
2881
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
7
5324
helpwithcode
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 date System.out.println(string_dob); s.Info_DOB=Date.valueOf(string_dob); runs perfectly fine in the method insert() and throws up an...
1
1522
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 ( , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ) SELECT ., ., ., LTrim(.) AS Expr1, LTrim(.) AS ,...
5
13324
matheussousuke
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 http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.