LAE

 View Only
Expand all | Collapse all

Week-day calculation

  • 1.  Week-day calculation

    Employee
    Posted 04-18-2017 13:32

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Cindy

    I am working with some date values, open_date and closed_date. I am using dateSubtract to get a number of days between the dates, but I really need to exclude weekend days from my output. I know there must be a way to do that, but I can't figure it out. Help!

    Cindy Clark


  • 2.  RE: Week-day calculation

    Employee
    Posted 04-18-2017 13:45

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    The function weekday() will tell you the day of the week a date falls on. 0 is Sunday and 6 is Saturday, then everything else in between.


  • 3.  RE: Week-day calculation

    Employee
    Posted 04-18-2017 13:50

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Cindy

    Right, but I am only getting 2 dates, open and closed--they are always a weekday. I can't really figure out how to incorporate the weekday function to reduce my calculation if a day is Sat or Sun.


  • 4.  RE: Week-day calculation

    Employee
    Posted 04-18-2017 14:01

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    How about something like this graph? You can have an open and close date, and then the Filter will count the number of weekend days and weekday days there was between those 2 dates.

    weekdays.brg


  • 5.  RE: Week-day calculation

    Employee
    Posted 04-19-2017 01:12

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: awilliams1024

    Hi Cindy,

    you could also use the Calculate Workdays node. The node provides the number of working days between the specified StartDate and EndDate values.

    Calculate_Workdays.brg

    In addition to providing a count of the total number of workdays, the node can be configured to exclude Public Holidays and/or an individual's vacation days that fall between the StartDate and EndDate values.

    An example of using Public Holidays in the calculation can be found in the following forum post:

    http://community.lavastorm.com/threa...n-in-LAE-graph

    Regards,
    Adrian


  • 6.  RE: Week-day calculation

    Employee
    Posted 04-19-2017 07:16

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Cindy

    Perfect! Thank you for the quick responses!


  • 7.  RE: Week-day calculation

    Employee
    Posted 05-15-2019 22:45

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: metin.erzen

    Thanks for solution.But I want to add national holiday list to holidays. How I can do it?


  • 8.  RE: Week-day calculation

    Employee
    Posted 05-16-2019 04:50

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    There's no BRAINScript for that and of course what day is a holiday depends on the location you're interested in. I had a quick look on Google and this site looks like it offers an API to query when holidays are. I didn't try it out, but if it works like I think you could use a HTTP node to get a list of holidays and check if today is on that list or not.


  • 9.  RE: Week-day calculation

    Employee
    Posted 05-16-2019 05:17

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: awilliams1024

    The incorporation of national (public) holidays into the calculations was covered in the example graph for the Calculate Workdays here:

    http://community.lavastorm.com/threa...ulate+workdays

    See the post at the bottom of the page. Public holidays can be specified as a literal using a comma-separated list of dates or can be obtained from an input field


  • 10.  RE: Week-day calculation

    Employee
    Posted 05-16-2019 05:30

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: awilliams1024

    The example also includes a use case for downloading the holidays from a web service


  • 11.  RE: Week-day calculation

    Employee
    Posted 05-17-2019 03:45

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: serif.gulsun

    hello guy,

    you can use codes

    node:nationality
    bretype:core::Composite
    editor:Label=nationality
    editor:sortkey=5cde8f2b355d04c7
    editor:XY=970,190
    node:Dates_Data
    bretype:core::Static Data
    editor:Label=Dates Data
    editor:sortkey=5c9894df3bee7f23
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    Start Date:date
    2019-04-25
    2019-04-26
    2019-05-31
    2019-05-28
    2019-03-29
    2019-03-30
    2019-03-31
    2019-04-01
    2018-04-02
    2018-07-04
    2018-12-31
    2019-02-28
    2019-03-01
    2019-04-12
    EOX
    editor:XY=910,110
    end:Dates_Data

    node:Calculate_Workday_Adusted_Dates_2
    bretype:core::Filter
    editor:Label=Calculate Workday Adusted Dates
    editor:sortkey=5c9899900bc23110_2
    input:@40fd2c74167f1ca2/=XRef_2.457826825d7c2de0
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX

    workDayOffset = 15
    sign = 1
    incrementedDays = 0
    newDate = 'Start Date'
    while incrementedDays < abs(workDayOffset) {
    newDate = dateAdjust(newDate, sign, "days")
    if weekday(newDate) > 0 and weekday(newDate) < 6 and
    not('NATIONALITY_DATE'.str().strFind(newDate.str() )>-1) then {
    incrementedDays = incrementedDays + 1
    }
    }


    emit *, newDate as "Adjusted_Date"
    exclude 'NATIONALITY_DATE'

    EOX
    editor:XY=1230,170
    end:Calculate_Workday_Adusted_Dates_2

    node:Agg_Ex
    bretype:core::Agg Ex
    editor:sortkey=5cdcff5e5ed6587f
    input:@4b4668c040aa5a85/=NATIONALITY_DATE.40fe6c55598828e5
    output:@4b4668e708143fb4/=
    prop:GroupBy=<<EOX
    1
    EOX
    prop:Script=<<EOX
    NATIONALITY_DATE = groupString('NATIONALITY_DATE',",")
    emit NATIONALITY_DATE
    where lastInGroup

    EOX
    prop:SortInput=true
    editor:XY=910,250
    node:Bypass
    bretype:::Bypass
    editor:shadow=4b467f7e02db3a85
    input:@4b467f7e129d45c1/=
    input:@4b467f830ffe047b/=
    output:@40fd2c7436717256/=
    end:Bypass

    node:Sort
    bretype:::Sort
    editor:shadow=4b467f8972dc33df
    input:@40fd2c743ebf4304/=
    output:@40fd2c746a2a3b47/=
    end:Sort

    node:Agg
    bretype:::Agg
    editor:shadow=4b467f9b3d5028c0
    input:@40fd2c7427456e5b/=
    output:@40fd2c744c862db0/=
    end:Agg

    end:Agg_Ex

    node:XRef_2
    bretype:core::X-Ref
    editor:sortkey=5cdcffed0f5c3c74
    input:@45781ca80c2802d0/=Dates_Data.40fe6c55598828e5
    input:@45781ca971fe502f/=Agg_Ex.4b4668e708143fb4
    output:@45781cad02e051b0/=
    output:@457826825d7c2de0/=
    output:@4578268450ad5d88/=
    prop:LeftInputKey=<<EOX
    1
    EOX
    prop:RightInputKey=<<EOX
    1
    EOX
    prop:SortLeftInput=true
    prop:SortRightInput=true
    editor:XY=1020,170
    node:Sort_2
    bretype:::Sort
    editor:shadow=45782670131b71e8
    input:@40fd2c743ebf4304/=
    output:@40fd2c746a2a3b47/=
    end:Sort_2

    node:Bypass_3
    bretype:::Bypass
    editor:shadow=4578267017753cec
    input:@45782010749f0c96/=
    input:@457820124fef7658/=
    output:@40fd2c7436717256/=
    end:Bypass_3

    node:Join
    bretype:::Join
    editor:shadow=457826701862249e
    input:@40fd2c745b6d7704/=
    input:@40fd2c74504921cd/=
    output:@40fd2c7430f76546/=
    output:@457826cc03a465f4/=
    output:@457826cc510c69e0/=
    end:Join

    node:Bypass
    bretype:::Bypass
    editor:shadow=4578267041681261
    input:@45782010749f0c96/=
    input:@457820124fef7658/=
    output:@40fd2c7436717256/=
    end:Bypass

    node:Sort
    bretype:::Sort
    editor:shadow=4578267075a60d09
    input:@40fd2c743ebf4304/=
    output:@40fd2c746a2a3b47/=
    end:Sort

    end:XRef_2

    node:NATIONALITY_DATE
    bretype:core::Static Data
    editor:Label=NATIONALITY_DATE
    editor:sortkey=5cde8e9d43040fff
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    NATIONALITY_DATE:date
    2021-01-01
    2021-04-23
    2021-05-12
    2021-05-13
    2021-05-14
    2021-05-19
    2021-07-15
    2021-07-19
    2021-07-20
    2021-07-21
    2021-07-22
    2021-07-23
    2021-08-30
    2021-10-28
    2021-10-29
    2017-05-01
    2017-05-19
    2017-06-26
    2017-06-27
    2017-08-30
    2017-08-31
    2017-09-01
    2017-09-04
    2018-01-01
    2018-04-23
    2018-05-01
    2018-06-14
    2018-06-15
    2018-08-20
    2018-08-21
    2018-08-22
    2018-08-23
    2018-08-24
    2018-08-30
    2018-10-29
    2019-01-01
    2019-04-23
    2019-05-01
    2019-06-04
    2019-06-05
    2019-06-06
    2019-06-07
    2019-07-15
    2019-08-12
    2019-08-13
    2019-08-14
    2019-08-30
    2019-10-28
    2019-10-29
    2020-01-01
    2020-04-23
    2020-05-01
    2020-05-19
    2020-05-25
    2020-05-26
    2020-07-15
    2020-07-30
    2020-07-31
    2020-08-03
    2020-10-28
    2020-10-29
    EOX
    editor:XY=780,250
    end:NATIONALITY_DATE

    end:nationality