Date & Time Input
am 17.01.2008 08:58:09 von 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?
Re: Date & Time Input
am 17.01.2008 09:13:28 von zzzxtreme
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=A0pm, "Tamer Ibrahim" wrote:
> Hi,
> I have two different text boxes. One is for reading user input date and th=
e
> 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?
Re: Date & Time Input
am 17.01.2008 09:17:50 von mark
"Tamer Ibrahim" wrote in message
news:OcWQm6NWIHA.4768@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
Re: Date & Time Input
am 17.01.2008 09:25:32 von mark
wrote in message
news:0fe9b3eb-6f6d-4349-a0e6-db45c88891fc@e6g2000prf.googleg roups.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
Re: Date & Time Input
am 18.01.2008 00:23:02 von mily242
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:
> wrote in message
> news:0fe9b3eb-6f6d-4349-a0e6-db45c88891fc@e6g2000prf.googleg roups.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
>
>