Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Week-day calculation

  1. #1

    Smile Week-day calculation

    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. #2
    Lavastorm Employee gmullin's Avatar
    Join Date
    May 2014
    Location
    Chicago
    Posts
    185

    Default

    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. #3

    Default

    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. #4
    Lavastorm Employee gmullin's Avatar
    Join Date
    May 2014
    Location
    Chicago
    Posts
    185

    Default

    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. #5
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    244

    Default

    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. #6

    Default

    Perfect! Thank you for the quick responses!

  7. #7

    Default

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

  8. #8
    Lavastorm Employee gmullin's Avatar
    Join Date
    May 2014
    Location
    Chicago
    Posts
    185

    Default

    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. #9
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    244

    Default

    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. #10
    Lavastorm Employee
    Join Date
    Nov 2012
    Location
    Warrington, UK
    Posts
    244

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •