473,544 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert Time into SmallDateTime Column?

I have an asp page which the user enters a time(e.g. 12:21). I need to
insert this time into a SQL Server DB, which has a smalldatetime column.

I have tried everything I can think of (such as CDate, TimeValue,
FormatDateTime etc) to convert the time string, into a valid time. However,
the insert always try to insert a datetime datatype (e.g. 12/12/1899
12:21:00).

I am trying to process the insert through ado, eg:

objRS.AddNew
objRS("Field1") = strText
objRS("DateFiel d") = dteValue
objRS.Update

Any suggestions as to how I can solve this?

--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures
Jul 19 '05 #1
4 12892
SQL Server will always add a date component. If the date is always
12/12/1899, can't you just ignore the date part???
http://www.aspfaq.com/2206

(Also, SQL Server would put 1900-01-01 as the date, so I think that's
VBScript adding the date for you. And finally, use an INSERT statement
instead of rs.AddNew.)

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"James Goodman" <j a m e s@norton-associates.co.u k> wrote in message
news:bu******** **@hercules.bti nternet.com...
I have an asp page which the user enters a time(e.g. 12:21). I need to
insert this time into a SQL Server DB, which has a smalldatetime column.

I have tried everything I can think of (such as CDate, TimeValue,
FormatDateTime etc) to convert the time string, into a valid time. However, the insert always try to insert a datetime datatype (e.g. 12/12/1899
12:21:00).

I am trying to process the insert through ado, eg:

objRS.AddNew
objRS("Field1") = strText
objRS("DateFiel d") = dteValue
objRS.Update

Any suggestions as to how I can solve this?

--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures

Jul 19 '05 #2
My problem is not that I cant ignore the date part of the time inserted.

I simply cannot insert anything into a smalldatetime field from asp.

Can you give me, or point me in the direction of an example for using an
insert command instead of objRS.AddNew etc?

--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures
Jul 19 '05 #3
sql = "INSERT table_name(smal ldatetime_colum n_name) VALUES('2004012 1
09:35')"
connObject.exec ute sql,,129

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"James Goodman" <j a m e s@norton-associates.co.u k> wrote in message
news:bu******** **@sparta.btint ernet.com...
My problem is not that I cant ignore the date part of the time inserted.

I simply cannot insert anything into a smalldatetime field from asp.

Can you give me, or point me in the direction of an example for using an
insert command instead of objRS.AddNew etc?

--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures

Jul 19 '05 #4
Perfect...

Thanks :)

--
Cheers,

James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures
Jul 19 '05 #5

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

Similar topics

2
16055
by: ImraneA | last post by:
Hi there Application : Access v2K/SQL 2K Jest : Using sproc to append records into SQL table Jest sproc : 1.Can have more than 1 record - so using ';' to separate each line from each other.
18
10251
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the date and time, but my script is erroring. '-- Get login date and time cmdLoginDate = Date() cmdLoginTime = Time()
6
5197
by: teddysnips | last post by:
I have a table called WorkItem. It models a chunk of work done during a working day. It has two columns that I'm interested in: Start (smalldatetime) - the TIME the work block is begun Duration (int) - the duration in minutes of the work block. In another table called OvertimeRates I have information about rate multipliers and a...
0
4475
by: ImraneA | last post by:
Hi there I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K. Wish to provide some knowledge gained back to community - hopefully help others. 1.Question how do you test stored procedure from SQL Server vs MS Access point of view ?
0
3700
by: Scarab | last post by:
Hi all, When I use following sql to get data in stored procedure, error occurs: insert into #tmp EXECUTE dbo.prc_1 @date1,@date1 Here is the source code, Thanks CREATE TABLE ( NULL , NULL ) ON
6
7640
by: SQL Server | last post by:
I've been working this for a while. Kind of new to SQL Server functions and not seeing what I am doing wrong. I have this function CREATE FUNCTION dbo.test (@Group varchar(50)) RETURNS smalldatetime AS BEGIN Declare @retVal varchar(10) (SELECT @retVal= MIN() FROM dbo.t_master_schedules WHERE (event_id = 13) AND (group_ =@Group))...
9
2264
by: rhaazy | last post by:
Using MS SQL 2000 I have a stored procedure that processes an XML file generated from an Audit program. The XML looks somewhat like this: <ComputerScan> <scanheader> <ScanDate>somedate&time</ScanDate>
10
8198
by: teddysnips | last post by:
SQL Server 2000 (DDL below) If I try to run this code in QA: SET IDENTITY_INSERT tblAdminUsers ON INSERT INTO tblAdminUsers (fldUserID, fldUsername, fldPassword, fldFullname,
4
6649
jamesd0142
by: jamesd0142 | last post by:
i have a column in my database called passwordchanged of datatype smalldatetime(4) i want to add a record to this with the format 'DD/MM/YYYY' how can i do this?
0
7424
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7376
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5909
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5297
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4918
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
988
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.