This is an archive of the Maximo Yahoo Community. The content of this pages may be a sometimes obsolete so please check post dates.
Thanks to the community owner Christopher Wanko for providing the content.
Has anyone created an escalation to set a target start date, but it needs to ignore non working days.. Weekends would be a good example of non working days..
I did something similar for workflow assignment escalations, but I had to
write a user-defined function in SQL Server to do it. The Escalation calls
the function, of course.
Shannon Rotz
From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com] On Behalf Of
shannon sutton
Sent: December-19-12 7:39 AM
To: MAXIMO@yahoogroups.com
Subject: [MAXIMO List] Escalation to Ignore Non-Working Days
Has anyone created an escalation to set a target start date, but it needs to
ignore non working days.. Weekends would be a good example of non working
days..
That is good to know.. I already have a function..
Thanks,
________________________________
From: Incomm Solutions Inc. <shannonrotz@yahoo.ca>
To: MAXIMO@yahoogroups.com
Sent: Wednesday, December 19, 2012 1:35 PM
Subject: RE: [MAXIMO List] Escalation to Ignore Non-Working Days
I did something similar for workflow assignment escalations, but I had to
write a user-defined function in SQL Server to do it. The Escalation calls
the function, of course.
Shannon Rotz
From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com] On Behalf Of
shannon sutton
Sent: December-19-12 7:39 AM
To: MAXIMO@yahoogroups.com
Subject: [MAXIMO List] Escalation to Ignore Non-Working Days
Has anyone created an escalation to set a target start date, but it needs to
ignore non working days.. Weekends would be a good example of non working
days..
Any chance you could share a sample?
--- In MAXIMO@yahoogroups.com, "Incomm Solutions Inc." <shannonrotz@...> wrote:
>
> I did something similar for workflow assignment escalations, but I had to
> write a user-defined function in SQL Server to do it. The Escalation calls
> the function, of course.
>
>
>
>
>
> Shannon Rotz
>
>
>
>
>
> From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com] On Behalf Of
> shannon sutton
> Sent: December-19-12 7:39 AM
> To: MAXIMO@yahoogroups.com
> Subject: [MAXIMO List] Escalation to Ignore Non-Working Days
>
>
>
>
>
> Has anyone created an escalation to set a target start date, but it needs to
> ignore non working days.. Weekends would be a good example of non working
> days..
>
>
>
>
>
>
>
>
>
Here's the function I used . contrary to my boasting before: now that I'm
looking at it, I'm pretty sure that I grabbed this off the Internet.
CREATE FUNCTION BDATEDIFF(@startdate as DATETIME, @enddate as DATETIME)
RETURNS INT
AS
BEGIN
DECLARE @res int
SET @res = (DATEDIFF(dd, @startdate, @enddate) + 1)
-(DATEDIFF(wk, @startdate, @enddate) * 2)
-(CASE WHEN
DATEPART(dw, @startdate) = 1 THEN 1 ELSE 0 END)
-(CASE WHEN
DATEPART(dw, @enddate) = 7 THEN 1 ELSE 0 END)
RETURN @res
END
I don't have the Escalation SQL, but if I remember correctly, it was set to
fire on the 2nd working day, which was:
Bdatediff(startdate,getdate()) = 2
Shannon Rotz
From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com] On Behalf Of
Jason Verly
Sent: December-19-12 2:51 PM
To: MAXIMO@yahoogroups.com
Subject: Re: [MAXIMO List] Escalation to Ignore Non-Working Days
Any chance you could share a sample?
--- In MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com> , "Incomm
Solutions Inc." <shannonrotz@...> wrote:
>
> I did something similar for workflow assignment escalations, but I had to
> write a user-defined function in SQL Server to do it. The Escalation calls
> the function, of course.
>
>
>
>
>
> Shannon Rotz
>
>
>
>
>
> From: MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com>
[mailto:MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com> ] On Behalf
Of
> shannon sutton
> Sent: December-19-12 7:39 AM
> To: MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com>
> Subject: [MAXIMO List] Escalation to Ignore Non-Working Days
>
>
>
>
>
> Has anyone created an escalation to set a target start date, but it needs
to
> ignore non working days.. Weekends would be a good example of non working
> days..
>
>
>
>
>
>
>
>
>
Examples for Oracle here
http://stackoverflow.com/questions/3450965/determine-if-oracle-date-is-on-a-weekendbut
to check holidays you'll need to build a list of holiday dates to
track
against.
On Wed, Dec 19, 2012 at 3:21 PM, Incomm Solutions Inc. <shannonrotz@yahoo.ca
> wrote:
> **
>
>
> Here's the function I used . contrary to my boasting before: now that I'm
> looking at it, I'm pretty sure that I grabbed this off the Internet.
>
> CREATE FUNCTION BDATEDIFF(@startdate as DATETIME, @enddate as DATETIME)
>
> RETURNS INT
>
> AS
>
> BEGIN
>
> DECLARE @res int
>
> SET @res = (DATEDIFF(dd, @startdate, @enddate) + 1)
>
> -(DATEDIFF(wk, @startdate, @enddate) * 2)
>
> -(CASE WHEN
> DATEPART(dw, @startdate) = 1 THEN 1 ELSE 0 END)
>
> -(CASE WHEN
> DATEPART(dw, @enddate) = 7 THEN 1 ELSE 0 END)
>
> RETURN @res
>
> END
>
> I don't have the Escalation SQL, but if I remember correctly, it was set to
> fire on the 2nd working day, which was:
>
> Bdatediff(startdate,getdate()) = 2
>
>
> Shannon Rotz
>
> From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com] On Behalf Of
> Jason Verly
> Sent: December-19-12 2:51 PM
> To: MAXIMO@yahoogroups.com
> Subject: Re: [MAXIMO List] Escalation to Ignore Non-Working Days
>
>
> Any chance you could share a sample?
>
> --- In MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com> , "Incomm
>
> Solutions Inc." <shannonrotz@...> wrote:
> >
> > I did something similar for workflow assignment escalations, but I had to
> > write a user-defined function in SQL Server to do it. The Escalation
> calls
> > the function, of course.
> >
> >
> >
> >
> >
> > Shannon Rotz
> >
> >
> >
> >
> >
> > From: MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com>
> [mailto:MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com> ] On
> Behalf
>
> Of
> > shannon sutton
> > Sent: December-19-12 7:39 AM
> > To: MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com>
> > Subject: [MAXIMO List] Escalation to Ignore Non-Working Days
> >
> >
> >
> >
> >
> > Has anyone created an escalation to set a target start date, but it needs
> to
> > ignore non working days.. Weekends would be a good example of non working
> > days..
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
>
>
I found this in a blog.. Seems like the best approach..
Suppose you have a table called AllDays, which has columns called theDay and IsPublicHoliday. Also suppose your @@DATEFIRST is set to 1, so that your weekends are days 1 and 7. You want to find the date which is @n days on from @StartDate.
WITHNumberedDays AS(SELECTtheDay,ROW_NUMBER()OVER(ORDERBYtheDay)ASDayNum FROMAllDays WHEREDATEPART(dw,theDay)NOTIN(1,7)ANDIsPublicHoliday =0ANDtheDay >@StartDate )SELECTtheDay FROMNumberedDays WHEREDayNum =@n ;
If you don't have a table called AllDays, then you can easily use a table of numbers, where theDay is DATEADD(day,num,@StartDate). You could do a LEFT JOIN to your list of ineligible days (which should be indexed, of course).
Shannon Dale SuttonMobile: 318-334-8002
________________________________
From: Chris Lawless <lawlessc@gmail.com>
To: MAXIMO@yahoogroups.com
Sent: Wednesday, December 19, 2012 6:26 PM
Subject: Re: [MAXIMO List] Escalation to Ignore Non-Working Days
Examples for Oracle here
http://stackoverflow.com/questions/3450965/determine-if-oracle-date-is-on-a-weekendbut
to check holidays you'll need to build a list of holiday dates to
track
against.
On Wed, Dec 19, 2012 at 3:21 PM, Incomm Solutions Inc. <shannonrotz@yahoo.ca
> wrote:
> **
>
>
> Here's the function I used . contrary to my boasting before: now that I'm
> looking at it, I'm pretty sure that I grabbed this off the Internet.
>
> CREATE FUNCTION BDATEDIFF(@startdate as DATETIME, @enddate as DATETIME)
>
> RETURNS INT
>
> AS
>
> BEGIN
>
> DECLARE @res int
>
> SET @res = (DATEDIFF(dd, @startdate, @enddate) + 1)
>
> -(DATEDIFF(wk, @startdate, @enddate) * 2)
>
> -(CASE WHEN
> DATEPART(dw, @startdate) = 1 THEN 1 ELSE 0 END)
>
> -(CASE WHEN
> DATEPART(dw, @enddate) = 7 THEN 1 ELSE 0 END)
>
> RETURN @res
>
> END
>
> I don't have the Escalation SQL, but if I remember correctly, it was set to
> fire on the 2nd working day, which was:
>
> Bdatediff(startdate,getdate()) = 2
>
>
> Shannon Rotz
>
> From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com] On Behalf Of
> Jason Verly
> Sent: December-19-12 2:51 PM
> To: MAXIMO@yahoogroups.com
> Subject: Re: [MAXIMO List] Escalation to Ignore Non-Working Days
>
>
> Any chance you could share a sample?
>
> --- In MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com> , "Incomm
>
> Solutions Inc." <shannonrotz@...> wrote:
> >
> > I did something similar for workflow assignment escalations, but I had to
> > write a user-defined function in SQL Server to do it. The Escalation
> calls
> > the function, of course.
> >
> >
> >
> >
> >
> > Shannon Rotz
> >
> >
> >
> >
> >
> > From: MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com>
> [mailto:MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com> ] On
> Behalf
>
> Of
> > shannon sutton
> > Sent: December-19-12 7:39 AM
> > To: MAXIMO@yahoogroups.com <mailto:MAXIMO%40yahoogroups.com>
> > Subject: [MAXIMO List] Escalation to Ignore Non-Working Days
> >
> >
> >
> >
> >
> > Has anyone created an escalation to set a target start date, but it needs
> to
> > ignore non working days.. Weekends would be a good example of non working
> > days..
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
>
>
------------------------------------
Email addresses you might need:
Posting: MAXIMO@yahoogroups.com
Join : MAXIMO-subscribe@yahoogroups.com
Leave : MAXIMO-unsubscribe@yahoogroups.com
Cry : MAXIMO-owner@yahoogroups.com
Group : http://groups.yahoo.com/group/MAXIMOYahoo! Groups Links