Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a univese filter based on a datetime object.

Status
Not open for further replies.

careymw

IS-IT--Management
Oct 8, 2010
41
US
I am trying to create a "previous week" filter in the universe to use to schedule a weekly report. I have a datetime field and it's giving me issues.

PSSI3_DM.AGENTACTIVITYLOG.STATUSDATETIME

I thought I could just do something like this.

PSSI3_DM.AGENTACTIVITYLOG.STATUSDATETIME >= dateadd(wk, datediff(wk, 7, getdate()), 0)
and
PSSI3_DM.AGENTACTIVITYLOG.STATUSDATETIME <= dateadd(wk, datediff(wk, 7, getdate()), 6)

or even this....
PSSI3_DM.AGENTACTIVITYLOG.STATUSDATETIME BETWEEN dateadd(wk, datediff(wk, 7, getdate()), 0) AND dateadd(wk, datediff(wk, 7, getdate()), 6)

How do you account for the time?
Previous week would be 11/24/2013 12:00:00 AM to 11/30/2013 11:59:00 PM
 
I am not a universe expert, but I would think PSSI3_DM.AGENTACTIVITYLOG.STATUSDATETIME >= dateadd(wk, datediff(wk, 7, getdate()), 0) would return information seven weeks in the future. PSSI3_DM.AGENTACTIVITYLOG.STATUSDATETIME >= dateadd(wk, datediff(d,-7, getdate()), 0) maybe closer to what want. As for the end date, not sure how to get that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top