Date & Time Input

  • Thread starter Thread starter Tamer Ibrahim
  • Start date Start date
T

Tamer Ibrahim

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?
 
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.
 
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);
 
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...
 
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
 
Back
Top