PC Review


Reply
Thread Tools Rate Thread

Date & Time Input

 
 
Tamer Ibrahim
Guest
Posts: n/a
 
      17th Jan 2008
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?



 
Reply With Quote
 
 
 
 
zzzxtreme@gmail.com
Guest
Posts: n/a
 
      17th Jan 2008
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.com> wrote:
> 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?


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      17th Jan 2008
"Tamer Ibrahim" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      17th Jan 2008
<(E-Mail Removed)> wrote in message
news:0fe9b3eb-6f6d-4349-a0e6-(E-Mail Removed)...

> 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

 
Reply With Quote
 
Milosz Skalecki [MCAD]
Guest
Posts: n/a
 
      17th Jan 2008
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:

> <(E-Mail Removed)> wrote in message
> news:0fe9b3eb-6f6d-4349-a0e6-(E-Mail Removed)...
>
> > 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
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input Mask - Date and Time =?Utf-8?B?QmVhZ2xl?= Microsoft Access 7 7th Nov 2007 10:10 PM
Input Mask for Date and Time =?Utf-8?B?TWV0aG90aWth?= Microsoft Access 2 26th Oct 2006 01:56 PM
Date/Time input Mask not available LMB Microsoft Access Forms 3 19th Sep 2006 02:04 AM
user input for date and time Rakesh Microsoft Excel Programming 0 11th Sep 2006 08:34 AM
How to Change Input String Data to Date/Time Date!! =?Utf-8?B?U2lkeg==?= Microsoft Access Form Coding 3 12th Apr 2006 07:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:10 AM.