Mohd Mohtashim
Mohd Mohtashim

Reputation: 1

Disallowed implicit conversion from data type datetime to data type int--

DECLARE @minusDate   DATETIME 
DECLARE @unixTimeConst  INTEGER 
DECLARE @unixBeginDate  DATETIME

SELECT 
    @counterWS =  COUNT(*) 
FROM  
    wmservice_min_max 
WHERE    
    @unixBeginDate + LASTTIME / @unixTimeConst  < @minusDate

LASTTIME is a column with datetime type.

I am getting the following error :

Disallowed implicit conversion from data type datetime to data type int, table 'wmservice_min_max', column 'LASTTIME'. Use the CONVERT function to run this query.

Upvotes: 0

Views: 1995

Answers (1)

ProblemSolver
ProblemSolver

Reputation: 644

U can modify the query like this, but i doubt logically what you are expecting you would get as output.

            DECLARE @minusDate   DATETIME 
            DECLARE @unixTimeConst  INTEGER 
            DECLARE @unixBeginDate  DATETIME
            DECLARE @counterWS INT

            SELECT 
                @counterWS =  COUNT(*) 
            FROM  
               #TEMP
            WHERE    
                CAST((@unixBeginDate + LASTTIME) AS INT) / @unixTimeConst  < @minusDate

Upvotes: 1

Related Questions