473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Date & Time Input

Hi,
I have two different text boxes. One is for reading user input date and the
other is for reading user input time.I'm using SQL 2005.
How can concatenate both of the two fields and send them as one data value
to be saved in a datetime field in the database?

Jan 17 '08 #1
4 5144
u can insert in table like this

'1/1/2001 12:00:00 AM'

month/day/year hour:minutes:seconds AM/PM

I do not know other format.

On Jan 17, 3:58*pm, "Tamer Ibrahim" <t.ge...@gmail.comwrote:
Hi,
I have two different text boxes. One is for reading user input date and the
other is for reading user input time.I'm using SQL 2005.
How can concatenate both of the two fields and send them as one data value
to be saved in a datetime field in the database?
Jan 17 '08 #2
"Tamer Ibrahim" <t.*****@gmail.comwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
I have two different text boxes. One is for reading user input date and
the
other is for reading user input time.I'm using SQL 2005.
How can concatenate both of the two fields and send them as one data value
to be saved in a datetime field in the database?
If e.g. the first TextBox contained "17 Jul 2008" and the second contained
"08:15"

Convert.ToDateTime(TextBox1.Text + " " + TextBox2.Text);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 17 '08 #3
<zz*******@gmail.comwrote in message
news:0f**********************************@e6g2000p rf.googlegroups.com...
You can insert in table like this

'1/1/2001 12:00:00 AM'
That it an ambiguous date format and should not be used...

E.g. '3/9/2001 12:00:00 AM" will be interpreted as either 3rd September or
9th March depending on the SQL Server settings and/or locale of the server
machine...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 17 '08 #4
I don't think it should be sent as string and parsed by SQL server, it's
safer to convert it to DateTime and passing as SqlDbType.DateTime (4 byte
number) as you showed in your second reply.

Regards
--
Milosz
"Mark Rae [MVP]" wrote:
<zz*******@gmail.comwrote in message
news:0f**********************************@e6g2000p rf.googlegroups.com...
You can insert in table like this

'1/1/2001 12:00:00 AM'

That it an ambiguous date format and should not be used...

E.g. '3/9/2001 12:00:00 AM" will be interpreted as either 3rd September or
9th March depending on the SQL Server settings and/or locale of the server
machine...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 18 '08 #5

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

Similar topics

1
by: Gerry | last post by:
Help needed with this: I have had a guestbook-page in Europe and will now have to move it to a US based-server. This makes the time-function showing time 6 hours wrong. The time should be GMT...
4
by: Gerry | last post by:
As I'm not a PHP-prgrammer at all, I just need Help with this: I have had a guestbook-page in Europe and will now have to move it to a US based-server. This makes the time-function showing time...
9
by: Shaiboy_UK | last post by:
Hi all, Hopefully something simple here. I have written a form that takes data from a text box and updates it into an Access database. However, I want to also pass the local user date and...
3
by: Agnes | last post by:
I know how to display Date only in the textbox . but How about the time ??? Can I put it into two separate textbox , but save in one datafield ? thanks a lot.
0
by: Wladimir Mutel | last post by:
Hi, In our legacy asp/web-application, we have date/time-input form in USA style (i.e. mm/dd/yyyy and 12hour-scale time with AM/PM). There is also some validation code on client side, and then...
3
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn...
1
by: aRTx | last post by:
<? /* Directory Listing Script - Version 2 ==================================== Script Author: Artani <artan_p@msn.com>. www.artxcenter.com REQUIREMENTS ============ This script requires...
1
by: adeebraza | last post by:
Hi, Every Body Following is code for Showing Actual Date & Time on the form and also record Date & Time of an event. See the following and use Call Modified when you want to record an event in...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
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 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.