Friday, March 23, 2012

getdate() rounded when runned in a job.

Hi all.
I am confusing on this matter so if anyone recognize this please let me
know.
Simple scenario.
I am using getdate() to fill datetime into a column in a table. All within a
prosedure.
Create a tmp table with datetime column.
Insert getdate()
Insert the temptable into a physical table with a datetime column.
Running the Exec prosedurename for Queryanalyzer I get the the whole
datetime value into the table. '2005-12-22 17:05:00,256'
BUT
Starting a Squeduled job running the same Exec I get only the date and it is
rounded upwards '2005-12-23 00:00:00,000'
Any ideas. I gues this is "by design" or something. I also think this
happens when running the job after 12 in the day.
thanx
geir"when running the job after 12 in the day."
That sounds misterious :-) No, something has to connvert the datetime
value to a less precise value. Does your proc perhaps use an input
paramter which is some kind of casted if you are calling it from a
scheduled job ?
DDL of the procedure and the job would be fine here. Jobs can be
scripted via Enterprise Manager into a sql file.
HTH, jens Suessmeyer.|||Hi Jens.
Sounds like some less precise value and "then I have to make a desission for
the time part and I decide to round up to the next date" issue.
I found out that if I Convert() the datetime as in Convert(varchar(25),
#tmpTable.DateTimeValue) in the moment when I insert into the pysical table
it all got inn. Right date and time.
What I don't understand is the differense between running in a job or in the
QueryAnalyzer.
So, it is solved. I have no ide why :-)
I run exact the same Exec with all hardcode values as parameters.
Exec custMPXrptFilExportSP 13, 3, 1, 17
go
CREATE PROCEDURE custXXXrptFilExportSP
@.KundeID int,
@.AvsAdresseID int,
@.LagerID int,
@.WebDataID int
AS

No comments:

Post a Comment