Disallowed implicit conversion from data type datetime to data type int, table

I get the following error code with the SQL provided. What on this green earth am I doing wrong here.

Msg 260, Level 16, State 1, Procedure Rpt_SalesSummaryAdopted_TEST_sproc_RAMS_RB, Line 136
Disallowed implicit conversion from data type datetime to data type int, table 'tempdb.dbo.#weeklytemp_________________________________________________________________________________________________________0001000009F3', column 'prod_cat'. Use the CONVERT function to run this query.
EE-SQL.txt
RUA Volunteer2?Tableau Trainer & Consultant Sales Exec.Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Show us in your code where you are inserting / updating the datetime column 'prod_cat' into an int column.

Wherever it's at, it's the equivalent of running the below code:
Declare @i int
SELECT @i = GETDATE()

Open in new window

0
PortletPaulfreelancerCommented:
I think it may be here, lines 163 & 164 of attachment:

FLOOR((CONVERT(INT, OH.OH_DELIVERY_DATE - @CurrToDate_pSDt,112))/7+1) AS WeekNumber,
CONVERT(char(8), @CurrToDate_pSDt+(7*FLOOR(CONVERT(INT, OH.OH_DELIVERY_DATE - @CurrToDate_pSDt)/7+1)-1),112) AS Week1_EndDate,

Open in new window


You should use the function DATEDIFF() for those date subtractions, it returns an int

e.g.
( DATEDIFF(day,H.OH_DELIVERY_DATE,@CurrToDate_pSDt) / 7 ) + 1 AS WeekNumber,

What are you expecting the next line to do please?
0
RUA Volunteer2?Tableau Trainer & Consultant Sales Exec.Author Commented:
[prod_cat] int, --left([prod_cat],2) int, --as ProdCatNo,
    [CurrWeekBeginDate] int
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

PortletPaulfreelancerCommented:
maybe an easier way to ask:

"Week1_EndDate"
What day of the week is this? (e.g. Friday? Sunday?)
If @CurrToDate_pSDt = 2013-09-14, what would Week1_EndDate equal?

(or provide a suitable example so we can see a wanted result)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RUA Volunteer2?Tableau Trainer & Consultant Sales Exec.Author Commented:
I fixed it........it was position. I had forgotten the rules of engagement. The problem involved position of the fields and preferences that I thought did not matter. It does...now I get it.
0
RUA Volunteer2?Tableau Trainer & Consultant Sales Exec.Author Commented:
That did it thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.