Power Pivot Code Debug

Aliq2014

New Member
Joined
Sep 10, 2014
Messages
46
Hello, I’m new to power pivot and learning how to code on my own as well. I need help debugging the following code: </SPAN>

DECLARE @FROMDATE AS VARCHAR(12)</SPAN>
DECLARE @TODATE AS VARCHAR(12)</SPAN>
DECLARE @PERIODDATE AS VARCHAR(12)</SPAN>
SET @PERIODDATE = '05/31/2015'</SPAN>
SELECT cast(floor(cast(dateadd(hour,datediff(hour,getutcdate(),getdate()),dateadd(s,JLJOURN.Local_DT,convert(datetime,'1990-01-01 00:00:00',102))) as float)) as datetime) as DDT</SPAN>
,T006001_CWTBL.ID</SPAN>
,T006001_CWTBL.FULL_NM</SPAN>
,T006001_CWTBL.BUS_DESC</SPAN>
,T001001_DOOR_GRP.LOC_BLD_CD</SPAN>
,T001001_DOOR_GRP.LOC_RPT_DESC</SPAN>
,COUNT(*) AS NUMSWIPES </SPAN>

From JLJOURN INNER JOIN T006001_CWTBL ON JLJOURN.User_PID = T006001_CWTBL.PERSON_ID</SPAN>
INNER JOIN Group_Member ON JLJOURN.Int_Data1 = Group_Member.Object_ID</SPAN>
INNER JOIN Groups ON Group_Member.Group_ID = Groups.Group_ID</SPAN>
INNER JOIN T001001_DOOR_GRP ON Groups.Group_Name = T001001_DOOR_GRP.MONITORING_GRP_DESC </SPAN>

WHERE cast(floor(cast(dateadd(hour,datediff(hour,getutcdate(),getdate()),dateadd(s,JLJOURN.Local_DT,convert(datetime,'1990-01-01 00:00:00',102))) as float)) as datetime) > convert(datetime,'11/30/2014',102) </SPAN>
AND cast(floor(cast(dateadd(hour,datediff(hour,getutcdate(),getdate()),dateadd(s,JLJOURN.Local_DT,convert(datetime,'1990-01-01 00:00:00',102))) as float)) as datetime) < convert(datetime,'06/01/2015',102) </SPAN>


AND T006001_CWTBL.BUS_DESC LIKE 'GOV%'</SPAN>
OR T006001_CWTBL.BUS_DESC LIKE 'IN GOV%'</SPAN>
AND T006001_CWTBL.PERIOD = convert(datetime,@PERIODDATE,102)</SPAN>

GROUP BY cast(floor(cast(dateadd(hour,datediff(hour,getutcdate(),getdate()),dateadd(s,JLJOURN.Local_DT,convert(datetime,'1990-01-01 00:00:00',102))) as float)) as datetime)</SPAN>
, ,T006001_CWTBL.ID</SPAN>
,T006001_CWTBL.FULL_NM</SPAN>
,T006001_CWTBL.BUS_DESC</SPAN>
,T001001_DOOR_GRP.LOC_BLD_CD</SPAN>
,T001001_DOOR_GRP.LOC_RPT_DESC</SPAN>

I’m trying to retrieve data from Dec2014, Jan2015, Feb2015, March2015, April2015 and May2015. </SPAN>
Do code I took from an experience developer and modified based on my needs. The problem is that I’m retrieving data from 2013 which I don’t need. Any help will be much appreciated thanks in advance. </SPAN>
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,221,848
Messages
6,162,415
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top