Inserting time and date in datetime field

Inserting time and date in datetime field

am 22.04.2005 21:28:51 von Drew

I have an ASP form with the following textboxes,

RegNo - Primary Key
EventDate - Date of Event
EventTime - Time of Event
EventCatID - Category of Event

How can I insert the date and time together, instead of using 2 datetime
fields?

Thanks,
Drew Laing

Re: Inserting time and date in datetime field

am 22.04.2005 21:32:33 von ten.xoc

I assume this is an Access database (it is always useful to tell us these
things).

Use NOW() instead of DATE() and TIME() in your INSERT query. It is better
to let the database figure these out than to use VBScript and embed the
string into the query...

--
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.

"Drew" wrote in message
news:uG2PFG3RFHA.1176@TK2MSFTNGP12.phx.gbl...
>I have an ASP form with the following textboxes,
>
> RegNo - Primary Key
> EventDate - Date of Event
> EventTime - Time of Event
> EventCatID - Category of Event
>
> How can I insert the date and time together, instead of using 2 datetime
> fields?
>
> Thanks,
> Drew Laing
>

Re: Inserting time and date in datetime field

am 22.04.2005 21:35:17 von unknown

What kind of database?

Ray at work

"Drew" wrote in message
news:uG2PFG3RFHA.1176@TK2MSFTNGP12.phx.gbl...
> I have an ASP form with the following textboxes,
>
> RegNo - Primary Key
> EventDate - Date of Event
> EventTime - Time of Event
> EventCatID - Category of Event
>
> How can I insert the date and time together, instead of using 2 datetime
> fields?
>
> Thanks,
> Drew Laing
>
>

Re: Inserting time and date in datetime field

am 22.04.2005 22:38:44 von Drew

Sorry about that...

SQL Server 2000 on Win2k

The user enters date and time in 2 different textboxes.

Thanks,
Drew

"Drew" wrote in message
news:uG2PFG3RFHA.1176@TK2MSFTNGP12.phx.gbl...
>I have an ASP form with the following textboxes,
>
> RegNo - Primary Key
> EventDate - Date of Event
> EventTime - Time of Event
> EventCatID - Category of Event
>
> How can I insert the date and time together, instead of using 2 datetime
> fields?
>
> Thanks,
> Drew Laing
>

Re: Inserting time and date in datetime field

am 22.04.2005 22:50:34 von ten.xoc

So, assuming you can change the table so that there is ONE column:

sql = "INSERT tbl(dtColumn) VALUES(#" & request.form("date") & " " &
request.form("time") & "#)"

I'll leave it as an exercise to the reader to deal with data validation, SQL
injection and date format/localization issues.

--
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.




"Drew" wrote in message
news:eJk%23It3RFHA.3156@TK2MSFTNGP15.phx.gbl...
> Sorry about that...
>
> SQL Server 2000 on Win2k
>
> The user enters date and time in 2 different textboxes.
>
> Thanks,
> Drew
>
> "Drew" wrote in message
> news:uG2PFG3RFHA.1176@TK2MSFTNGP12.phx.gbl...
>>I have an ASP form with the following textboxes,
>>
>> RegNo - Primary Key
>> EventDate - Date of Event
>> EventTime - Time of Event
>> EventCatID - Category of Event
>>
>> How can I insert the date and time together, instead of using 2 datetime
>> fields?
>>
>> Thanks,
>> Drew Laing
>>
>
>

Re: Inserting time and date in datetime field

am 22.04.2005 22:50:43 von rdanjou

You could format a string in your ASP page with the date and time values
entered by the user.
I don't know exactly what the users are entering in your page but you should
be able to figure this part out.
Insert the string into your dateTime column in this format.
'YYYYMMDD HH:MM:SS'

"Drew" wrote in message
news:eJk%23It3RFHA.3156@TK2MSFTNGP15.phx.gbl...
> Sorry about that...
>
> SQL Server 2000 on Win2k
>
> The user enters date and time in 2 different textboxes.
>
> Thanks,
> Drew
>
> "Drew" wrote in message
> news:uG2PFG3RFHA.1176@TK2MSFTNGP12.phx.gbl...
>>I have an ASP form with the following textboxes,
>>
>> RegNo - Primary Key
>> EventDate - Date of Event
>> EventTime - Time of Event
>> EventCatID - Category of Event
>>
>> How can I insert the date and time together, instead of using 2 datetime
>> fields?
>>
>> Thanks,
>> Drew Laing
>>
>
>

Re: Inserting time and date in datetime field

am 22.04.2005 22:50:46 von unknown

Concatenate them together and insert them into a datetime or smalldatetime
column (after validating).

Which part are you stuck on? How to do an insert? How to bring the two
values together in preparation for the insert? How to validate the data?
How to merge your existing data together into one column? Something else?

Ray at work


"Drew" wrote in message
news:eJk%23It3RFHA.3156@TK2MSFTNGP15.phx.gbl...
> Sorry about that...
>
> SQL Server 2000 on Win2k
>
> The user enters date and time in 2 different textboxes.
>
> Thanks,
> Drew
>
> "Drew" wrote in message
> news:uG2PFG3RFHA.1176@TK2MSFTNGP12.phx.gbl...
> >I have an ASP form with the following textboxes,
> >
> > RegNo - Primary Key
> > EventDate - Date of Event
> > EventTime - Time of Event
> > EventCatID - Category of Event
> >
> > How can I insert the date and time together, instead of using 2 datetime
> > fields?
> >
> > Thanks,
> > Drew Laing
> >
>
>