October 18, 2011 at 10:09 pm
Hi all ,
Its big question to me .. In our production server in some sp's to insert modified date and inserted date am using getdate() function .
Question is for very few records modifieddate is null even thoe it is inserted.
And for yeterday for one insetion operation inserted date is '20011-11-11' .
In both case am using getdate() function to use. I assigned that date to one variable and am using that while inserting .
Am very much sure about the code .
Still am not getting why it happened and how .. its big problem to fecth live reports with out proper date .
Please can body answere this ?
Thanks,
Ravi@sql
October 18, 2011 at 10:16 pm
Post the code.
Only way you can get a value like that is if you have dates stored as strings, which is not recommended.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 18, 2011 at 10:21 pm
No its a DateTime field only .
October 18, 2011 at 10:22 pm
ravi@sql (10/18/2011)
And for yeterday for one insetion operation inserted date is '20011-11-11' .
You cannot in any way put 20011-11-11 into a datetime field. It'll fail with a conversion error.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 18, 2011 at 10:22 pm
Would you mind posting the code. That would help us to look at further.
Whats the variable datatype?
October 18, 2011 at 10:26 pm
example of code
INSERT INTO CourseFeedback (Courseid,UserID,Feedbackxml,CreatedDate)
VALUES (@CourseId,@UserID,@Feedbackxml,GETDATE())
October 18, 2011 at 10:31 pm
ravi@sql (10/18/2011)
example of code
INSERT INTO CourseFeedback (Courseid,UserID,Feedbackxml,CreatedDate)
VALUES (@CourseId,@UserID,@Feedbackxml,GETDATE())
In both case am using getdate() function to use. I assigned that date to one variable and am using that while inserting .
This is contrdictory. Where is the assignment of the variable here in the code? Or Am I missing something here?
October 18, 2011 at 10:37 pm
example of code
declare @date datetime
set @date=getdate()
INSERT INTO CourseFeedback (Courseid,UserID,Feedbackxml,CreatedDate)
VALUES (@CourseId,@UserID,@Feedbackxml,@date)
October 18, 2011 at 10:48 pm
example of code
INSERT INTO CarFeedback(Carid,UserID,Feedback,CreatedDate)
VALUES (@Carid,@UserID,@Feedback,getdate())
October 18, 2011 at 10:53 pm
No clues on this. However let me ask you something out of box whats the SQL server version you installed?
October 18, 2011 at 11:11 pm
Microsoft SQL Server 2005 - 9.00.1399.06
October 18, 2011 at 11:15 pm
Ok, its worth looking at the below MSDN. I am not sure as long as I dont have any idea about your complete code.
http://support.microsoft.com/kb/958547
Meanwhile, we exepect our experts will have something to guide....
October 18, 2011 at 11:55 pm
ravi@sql (10/18/2011)
example of code
declare @date datetime
set @date=getdate()
INSERT INTO CourseFeedback (Courseid,UserID,Feedbackxml,CreatedDate)
VALUES (@CourseId,@UserID,@Feedbackxml,@date)
The only way that can return anything other than the correct date is if the server's date is set wrong. And it can't return anything like you described in your initial post (20011-11-11)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply