Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Problem with dates

Author  Topic 

OMB
Yak Posting Veteran

88 Posts

Posted - 2002-06-25 : 03:31:42
Hi I have the follwing code that inserts a date into a stored proc from ASP


CmdSP.Parameters.Append CmdSP.CreateParameter("@ProposedReleaseDate", adVarChar, adParaminput, 20, ConvertToDate(Request.Form("PROPOSEDRELEASEDATE") & ""))


the stored proc is as follows:


CREATE PROC spAddNewsStory
@UserName VARCHAR(200),
@Password VARCHAR(10),
@UniqueID VARCHAR(50),
@UniqueCodeFromServer VARCHAR(200) = NULL,
@StoryText TEXT,
@Headline VARCHAR(200) = NULL,
@ProposedReleaseDate VARCHAR(200) ,
@ProposedReleaseTime VARCHAR(200),
@CompaniesID NUMERIC(18,0) = NULL,
@Status INT OUTPUT

AS BEGIN

DECLARE @Count1 NUMERIC(18,0),@Count2 NUMERIC(18,0),@UserID NUMERIC(18,0) ,@ID VARCHAR(6), @CompanyName VARCHAR(200)



SELECT @Count1 = count(*) ,@UserId = MAX(USERDetailsID)
FROM UserDetails (NOLOCK)
WHERE UserName = @UserName
AND Password = @Password
AND UniqueCodeFromServer = @UniqueCodeFromServer
AND Valid = 1


-- we must check that the unique id is valid
SELECT @Count2 = count(*)
FROM RegisteredComputers (NOLOCK)
WHERE Uniqueid = @Uniqueid
AND Valid = 1

SELECT @ID = ID, @CompanyName = CompanyName
FROM Companies (NOLOCK)
WHERE CompaniesID = @CompaniesID



IF (@Count1 > 0) AND (@Count2 > 0)
BEGIN
INSERT INTO News (UserID,Story,DateSent,ReferenceCode,Headline,SentToNewstrack,CompaniesID,ID,CompanyName,ProposedReleaseDate,ProposedReleaseTime)
VALUES (@UserID,@StoryText,getdate(),@UniqueCodeFromServer,@Headline,0,@CompaniesID,@ID,@CompanyName,@ProposedReleaseDate,@ProposedReleaseTime)
Select @Status = 1
END
ELSE
BEGIN
Select @Status = 0
END


END
go


However it keeps on inserting a date of 01/01/1900.

any advise will be greatly appreciated.

THANXS

OMB

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2002-06-25 : 03:54:02
SQL Server by default inserts '01/01/1900' in date column if u try to insert a blank in a column with datatype as datetime. so either insert a date or null in datetime field.

Go to Top of Page
   

- Advertisement -