Home > Archive > MS SQL Server > January 2006 > DateTime problem....









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author DateTime problem....
BenUK

2006-01-31, 7:23 am

I run the below code on several servers via a scheduled jobs, on one server
the job fails reporting "Error converting data type char to datetime.
[SQLSTATE 42000] (Error 8114)", Any ideas on where to start troubleshooting
this server, I can't think?

DECLARE @BAKDate Char(10)

SET @BAKDate = CONVERT(Char(10),Get
Date()-28, 102)
EXEC sp_delete_backuphist
ory @BAKDate
Uri Dimant

2006-01-31, 7:23 am

Hi
CONVERT(Char(10),Get
Date()-28, 112)





"BenUK" <BenUK@discussions.microsoft.com> wrote in message
news:DC58F65D-C5AC-4FA4-A014- 8C4B492B9196@microso
ft.com...
>I run the below code on several servers via a scheduled jobs, on one server
> the job fails reporting "Error converting data type char to datetime.
> [SQLSTATE 42000] (Error 8114)", Any ideas on where to start
> troubleshooting
> this server, I can't think?
>
> DECLARE @BAKDate Char(10)
>
> SET @BAKDate = CONVERT(Char(10),Get
Date()-28, 102)
> EXEC sp_delete_backuphist
ory @BAKDate



Jens

2006-01-31, 7:23 am

Wh are you back casting the value to char if a datetime is needed ?

DECLARE @BAKDate datetime


SET @BAKDate = GetDate()-28
EXEC sp_delete_backuphist
ory @BAKDate


HTH, Jens Suessmeyer.

BenUK

2006-01-31, 7:23 am

Just reran the job manually, using original code and success, I figure it
must have been due to the code looking to last year and getting confused...
....strange???

"Uri Dimant" wrote:

> Hi
> CONVERT(Char(10),Get
Date()-28, 112)
>
>
>
>
>
> "BenUK" <BenUK@discussions.microsoft.com> wrote in message
> news:DC58F65D-C5AC-4FA4-A014- 8C4B492B9196@microso
ft.com...
>
>
>

BenUK

2006-01-31, 7:23 am

Cutting the time element...

"Jens" wrote:

> Wh are you back casting the value to char if a datetime is needed ?
>
> DECLARE @BAKDate datetime
>
>
> SET @BAKDate = GetDate()-28
> EXEC sp_delete_backuphist
ory @BAKDate
>
>
> HTH, Jens Suessmeyer.
>
>

Scott Morris

2006-01-31, 9:23 am

"BenUK" <BenUK@discussions.microsoft.com> wrote in message
news:6958188D-93F6-42C1-8F97- 2E75001DA6C9@microso
ft.com...
> Cutting the time element...


Well, the argument is defined as a datetime. You are relying on an unsafe
character format AND implicit conversion - hence, the error.

http://www.karaszi.com/sqlserver/in...e
Portion



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com