[Question]
  [
I just had a genius idea for making the work-life easier - a countdown to a specific date which only counts workdays.
---
The basic task is to create a countdown to a specific date which only includes the workdays in the countdown.
As workday counts *Monday*, *Tuesday*, *Wednesday*, *Thursday* and *Friday*.
**The Input** should be a specific date in the "unofficial" European standard format `dd.MM.yyyy` and must be today or a day in the future.
**The Output** should only be the number of days left.
As it's [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") the shortest code wins.
---
**Test case:**
```
  Today    |   Input    | Output
10.12.2018 | 17.12.2018 |    5
02.10.2018 | 16.10.2018 |   10
```
---
*If I missed a few things in the question, please forgive me - it's my first question :)*
**EDIT:**  
* You can use `false` as output instead of `0` *<- but it's not beautiful*
* No need for respecting DST
  
[Answer]
## [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~130~~ ~~128~~ ~~133~~ ~~131~~ ~~124~~ ~~123~~ ~~122~~ ~~121~~ 120 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
žežfžg)V0[Y`UD3‹©12*+>₂*T÷®Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD<i\28X+ë<7%É31α}‹iY¬>0ëY1¾ǝDÅsD12‹i>1ë\1Dǝ¤>2}}ǝVYI'.¡Q#
```
I'm out of my mind..
For the golfing language 05AB1E it doesn't matter at all whether the input is with `.` or `-`. However, 05AB1E doesn't have any builtins for Date objects or calculations. The only builtin regarding dates it has is today's year/month/day/hours/minutes/seconds/microseconds.
So because of that, almost all of the code you see are manual calculations to go to the next day, and calculating the day of the week.
+5 bytes due to a part I forgot in Zeller's formula (year-1 for months January and February)..  
-1 byte thanks to @Grimmy, by changing \$\left\lfloor{\frac{13(m+1)}{5}}\right\rfloor\$ to \$\left\lfloor{\frac{26(m+1)}{10}}\right\rfloor\$ in the code, since 05AB1E has single-byte builtins for both `26` and `10` (being `₂` and `T` respectively), as opposed to the 3 bytes of `13` and `5`.
[Try it online](https://tio.run/##yy9OTMpM/f//6L7Uo/vSju5L1wwziI5MCHUxftSw89BKQyMtbbtHTU1aIYe3H1oXcW7joZUXm1RdTEC8i01AciWYeWi7huaR9mJ/c1UjB@3IhItNjxo2GHif22FyeFqoi01mjJFFhPbh1Tbmqoc7jQ3PbawFmp0ZeWiNncHh1ZGGh/Ydn@tyuLXYxdAIJG5neHh1jKHL8bmHltgZ1dYenxsW6amud2hhoPL//4ameoYGekYGRkYA) or [Try it online with an emulated self-specified date of 'today'](https://tio.run/##yy9OTMpM/a8UUFqikKiQkliSqpCZp1CSkaqQll@Um1iikJKi6@urWwkECiX5CqXFqQqJxQqJOSWpRXmJJZllqQrFJYlFJZl56RDNGqm5pTlARgqEm5@moF6Sn5JYqa5ppRTDxaVkYKRraKBrZGBooaSue2jh/zCD6MiEUBfjRw07D600NNLStnvU1KQVcnj7oXUR5zYeWnmxSdXFBMS72AQkV4KZh7ZraB5pL/Y3VzVy0I5MuNj0qGGDgfe5HSaHp4W62GTGGFlEaB9ebWOuerjT2PDcxlqg2ZmRh9bYGRxeHWl4aN/xuS6HW4tdDI1A4naGh1fHGLocn3toiZ1Rbe3xuWGRnup6hxYGKv//b2imZ2igB3IrAA).
### Explanation:
*Wall of text incoming.*
In general, the code follows the following pseudo-code:
```
1   Date currentDate = today;
2   Integer counter = 0;
3   Start an infinite loop:
4*    If(currentDate is NOT a Saturday and currentDate is NOT a Sunday):
5       Counter += 1;
6*    currentDate += 1; // Set currentDate to the next day in line
7     If(currentDate == parsed input-string):
8       Stop the infinite loop, and output the counter
```
1) `Date currentDate = today;` is this part of the 05AB1E program:
```
že          # Push today's day
  žf        # Push today's month
    žg      # Push today's year
      )     # Wrap them into a single list
       V    # Pop and store this list in variable `Y`
```
2) `Integer counter = 0;` and 3) `Start an infinite loop:` are straight-forward in the 05AB1E program:
```
0     # Push 0 to the stack
 [    # Start an infinite loop
```
4) `If(currentDate is NOT a Saturday and currentDate is NOT a Sunday):` is the first hard part with manual calculations. Since 05AB1E has no Date builtins, we'll have to calculate the *Day of the Week* manually.
The general formula to do this is:
$${\displaystyle h=\left(q+\left\lfloor{\frac{13(m+1)}{5}}\right\rfloor+K+\left\lfloor{\frac{K}{4}}\right\rfloor+\left\lfloor{\frac{J}{4}}\right\rfloor-2J\right){\bmod{7}}}$$
Where for the months March through December:
* \$q\$ is the \$day\$ of the month (`[1, 31]`)
* \$m\$ is the 1-indexed \$month\$ (`[3, 12]`)
* \$K\$ is the year of the century (\$year \bmod 100\$)
* \$J\$ is the 0-indexed century (\$\left\lfloor {\frac {year}{100}}\right\rfloor\$)
And for the months January and February:
* \$q\$ is the \$day\$ of the month (`[1, 31]`)
* \$m\$ is the 1-indexed \$month + 12\$ (`[13, 14]`)
* \$K\$ is the year of the century for the previous year (\$(year - 1) \bmod 100\$)
* \$J\$ is the 0-indexed century for the previous year (\$\left\lfloor {\frac {year-1}{100}}\right\rfloor\$)
Resulting in in the day of the week \$h\$, where 0 = Saturday, 1 = Sunday, ..., 6 = Friday.  
[Source: Zeller's congruence](https://en.wikipedia.org/wiki/Zeller%27s_congruence)
We can see this in this part of the 05AB1E program:
```
Y             # Push variable `Y`
 `            # Push the day, month, and year to the stack
  U           # Pop and save the year in variable `X`
   D          # Duplicate the month
    3‹        # Check if the month is below 3 (Jan. / Feb.),
              # resulting in 1 or 0 for truthy/falsey respectively
      ©       # Store this in variable `®` (without popping)
       12*    # Multiply it by 12 (either 0 or 12)
          +   # And add it to the month
              # This first part was to make Jan. / Feb. 13 and 14
>             # Month + 1
 ₂*           # Multiplied by 26
   T÷         # Integer-divided by 10
®             # Push month<3 from variable `®` again
 Xα           # Take the absolute difference with the year
   ©          # Store this potentially modified year as new `®` (without popping)
    т%        # mYear modulo-100
D4÷           # mYear modulo-100, integer-divided by 4
®т÷©4÷        # mYear integer-divided by 100, and then integer-divided by 4
®·(           # mYear integer-divided by 100, doubled, and then made negative
)             # Wrap the entire stack into a list
 ć            # Extract the head (the counter variable that was also on the stack)
  s           # Swap so the calculated values above are as list at the top
   O          # Take the sum of this entire list
    7%        # And then take modulo-7 to complete the formula,
              # resulting in 0 for Saturday, 1 for Sunday, and [2, 6] for [Monday, Friday]
2@            # Check if the day is greater than or equal to 2 (so a working day)
```
5) `Counter += 1;` is straight-forward again:
```
     # The >=2 check with `2@` results in either 1 for truthy and 0 for falsey
+    # So just adding it to the counter variable is enough
```
6) `currentDate += 1; // Set currentDate to the next day in line` is again more complex, because we have to do it manually. So this will be expanded to the following pseudo-code:
```
a   Integer isLeapYear = ...;
b   Integer daysInCurrentMonth = currentDate.month == 2 ?
c                                 28 + isLeapYear
d                                :
e                                 31 - (currentDate.month - 1) % 7 % 2;
f   If(currentDate.day < daysInCurrentMonth):
g     nextDate.day += 1;
h   Else:
i     nextDate.day = 1;
j     If(currentDate.month < 12):
k       nextDate.month += 1;
l     Else:
m       nextDate.month = 1;
n       nextDate.year += 1;
```
Sources:  
~~[Algorithm for determining if a year is a leap year.](http://www.dispersiondesign.com/articles/time/determining_leap_years)~~ (EDIT: No longer relevant, since I use [an alternative method](https://codegolf.stackexchange.com/a/177019/52210) to check leap years which saved 7 bytes.)  
[Algorithm for determining the number of days in a month.](http://www.dispersiondesign.com/articles/time/number_of_days_in_a_month)
6a) `Integer isLeapYear = ...;` is done like this in the 05AB1E program:
```
Y             # Push variable `Y`
 `            # Push the days, month and year to the stack
  т‰          # Divmod the year by 100
    0K        # Remove all items "00" (or 0 when the year is below 100)
      θ       # Pop the list, and leave the last item
       4Ö     # Check if this number is visible by 4
         U    # Pop and save the result in variable `X`
```
Also used in [this 05AB1E answer of mine](https://codegolf.stackexchange.com/a/177019/52210), so there some example years are added to illustrate the steps.
6b) `currentDate.month == 2 ?` and 6c) `28 + isLeapYear` are done like this:
```
D            # Duplicate the month that is now the top of the stack
 <           # Decrease it by 1
  i          # And if this is now 1 (thus February):
   \         #  Remove the duplicated month from the top of the stack
    28X+     #  Add 28 and variable `X` (the isLeapYear) together
```
6d) `:` and 6e) `31 - (currentDate.month - 1) % 7 % 2;` are done like this:
```
ë           # Else:
 <          #  Month - 1
  7%        #  Modulo-7
    É       #  Is odd (shortcut for %2)
     31     #  Push 31
       α    #  Absolute difference between both
}           # Close the if-else
```
6f) `If(currentDate.day < daysInCurrentMonth):` is done like this:
```
‹     # Check if the day that is still on the stack is smaller than the value calculated
 i    # And if it is:
```
6g) `nextDate.day += 1;` is done like this:
```
Y       # Push variable `Y`
 ¬      # Push its head, the days (without popping the list `Y`)
  >     # Day + 1
   0    # Push index 0
        # (This part is done after the if-else clauses to save bytes)
}}      # Close the if-else clauses
  ǝ     # Insert the day + 1 at index 0 in the list `Y`
   V    # Pop and store the updated list in variable `Y` again
```
6h) `Else:` and 6i) `nextDate.day = 1;` are then done like this:
```
ë        # Else:
 Y       #  Push variable `Y`
  1      #  Push a 1
   ¾     #  Push index 0
    ǝ    #  Insert 1 at index 0 (days part) in the list `Y`
```
6j) `If(currentDate.month < 12):`:
```
D           # Duplicate the list `Y`
 Ås         # Pop and push its middle (the month)
   D12‹     # Check if the month is below 12
       i    # And if it is:
```
6k) `nextDate.month += 1;`:
```
>       # Month + 1
 1      # Push index 1
        # (This part is done after the if-else clauses to save bytes)
}}      # Close the if-else clauses
  ǝ     # Insert the month + 1 at index 1 in the list `Y`
   V    # Pop and store the updated list in variable `Y` again
```
6l) `Else:`, 6m) `nextDate.month = 1;` and 6n) `nextDate.year += 1;` are then done like this:
```
ë        # Else:
 \       #  Delete the top item on the stack (the duplicated month)
  1      #  Push 1
   D     #  Push index 1 (with a Duplicate)
    ǝ    #  Insert 1 at index 1 (month part) in the list `Y`
 ¤       #  Push its tail, the year (without popping the list `Y`)
  >      #  Year + 1
   2     #  Index 2
         # (This part is done after the if-else clauses to save bytes)
}}       # Close the if-else clauses
  ǝ      # Insert the year + 1 at index 2 in the list `Y`
   V     # Pop and store the updated list in variable `Y` again
```
And finally at 7) `If(currentDate == parsed input-string):` and 8) `Stop the infinite loop, and output the counter`:
```
Y          # Push variable `Y`
 I         # Push the input
  '.¡     '# Split it on dots
     Q     # Check if the two lists are equal
      #    # And if they are equal: stop the infinite loop
           # (And output the top of the stack (the counter) implicitly)
```
[Answer]
# Excel 24 Bytes
Assumes input in Cell A1
```
=NETWORKDAYS(NOW()+1,A1)
```
Uses built-in function. Unfortunately the function includes both today and the end date. OP has since clarified to not count today, so I add one to NOW so as to not count today.
To address comments on format of number, again, this is Excel standard:
[![enter image description here](https://i.stack.imgur.com/WScdh.png)](https://i.stack.imgur.com/WScdh.png)
[Answer]
# [R](https://www.r-project.org/), 76 bytes
[Please also have a look at this 72 byte R answer that is also locale-independent.](https://codegolf.stackexchange.com/a/173303/79980)
```
sum(!grepl("S",weekdays(seq(Sys.Date(),as.Date(scan(,""),"%d.%m.%Y"),1))))+1
```
[Try it online!](https://tio.run/##K/r/v7g0V0MxvSi1IEdDKVhJpzw1NTslsbJYozi1UCO4sljPJbEkVUNTJxHKKk5OzNPQUVLS1FFSTdFTzdVTjQSyDTWBQNvwv4GFnqGBnpGBocV/AA "R – Try It Online")
`weekdays` gives text days of week, so we count the days in the sequence between today and the input that do not contain `S`, and add one to the result.
[Answer]
# Java 10, ~~233~~ ~~232~~ 226 bytes
```
import java.util.*;d->{int r=0;var s=Calendar.getInstance();s.setTime(new Date());var e=s.getInstance();for(e.setTime(new java.text.SimpleDateFormat("dd.MM.yyyy").parse(d));!s.after(e);s.add(5,1))if(s.get(7)%7>1)r++;return r;}
```
Date always reminds me how verbose Java really is..
NOTE: There are now two shorter Java answers (below 175 bytes), [one with smart use of deprecated methods from earlier Java versions](https://codegolf.stackexchange.com/a/173151/52210) by *@LukeStevens*, and [one using the `java.time.LocalDate` that's new since Java 8](https://codegolf.stackexchange.com/a/173176/52210) by *@OlivierGrégoire*.
[Try it online.](https://tio.run/##fZBNSwMxEIbv@yvGgpBYm24KWmVpL36Ah4pQb@Ih3czW1N1kSWb7QdnfXrO1FxUMITAvz8zkfVdqrQYr/XkwVe08wSrWoiFTiosMYDiEFxVVVwB9ICx2hIPcNZaA9eUtT/JShQAzZew@ATCW0BcqR3juyqMAOZuTN3YJmscZ3m0CPGxzrMk4m0WqTeITSJHJ4RksTOCgB9N91@onabZWHsLkTpVotfJiifRkI21zZDwLIiC9mgqZxQ3cK4oiP7bgJPxiC@cZ/uCPVgm3JObRfIld/6PzlSLW01rMZmIXT4@LWvmATMfRZ0GoIppk2C1XWrOrS8m5KdhxHRvz8/FUct/vZx6p8RZ81h6yzmLdLMpo8eR07YyGKuZ2SuftHdTffL5TnO8CYSVcQ6KOLJWWWZGznrwWMhWjVN704tf@RVMp4h3JND2hbdIevgA)
**Explanation:**
```
import java.util.*;            // Required import for both Calendar and Date
d->{                           // Method with String parameter and integer return-type
  int r=0;                     //  Result-integer, starting at 0
  var s=Calendar.getInstance();//  Create a Calendar instance for the start-date
  s.setTime(new Date());       //  Set the start date to today
  var e=s.getInstance();       //  Create a Calendar instance for the end-date
  for(e.setTime(               //  Set the end date to:
        new java.text.SimpleDateFormat("dd.MM.yyyy")
                               //   Create a formatter for the "dd.MM.yyyy" format
         .parse(d));           //   And parse the input-String to a Date
      !s.after(e)              //  Loop as long as we haven't reached the end date yet
      ;                        //    After every iteration:
       s.add(5,1))             //     Increase the start-date by 1 day
    if(s.get(7)%7>1)           //   If the day of the week is NOT a Saturday or Sunday:
                               //   (SUNDAY = 1, MONDAY = 2, ..., SATURDAY = 7)
      r++;                     //    Increase the result-sum by 1
  return r;}                   //  Return the result-sum
```
[Answer]
# JavaScript (ES6), ~~116~~ 103 bytes
```
f=(d,n=+new Date)=>(D=new Date(n)).toJSON()<d.split`.`.reverse().join`-`&&(D.getDay()%6>0)+f(d,n+864e5)
```
[Try it online!](https://tio.run/##XY9BawIxEIXv@yvmUjNDTFhKK4JmT3vyUA/2Vgob3KxElkSSoIj0t69ZxVp6esy84b1v9vqo4zbYQxLOt2YYOoXt1CnuzAlqnQypCmv1mNARyeRXm/UH0rKV8dDb1MhGBnM0IRokuffWNaKZTLCWO5NqfUZ6mVUl8W5M5vPZm3mnYetd9L2Rvd8h@/StPoMCBhzwt4uIiqLzAW22yim4LKMhnT8hLcDCEl7LrJwTXAqAmEI@eQY44ArufU/qO3PuZPRVfj8mwejfD8gko0VO/Us6NvCMKUR1g@3GDeWzn@EK "JavaScript (Node.js) – Try It Online")
### How?
A JavaScript timestamp is defined as the number of *milliseconds* elapsed since the [UNIX epoch](https://en.wikipedia.org/wiki/Unix_time). The current timestamp is hold in the variable \$n\$.
At each iteration, we use \$n\$ to generate a date \$D\$ (as a JavaScript object). This date is converted to [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format with the `.toJSON()` method:
```
*YYYY*-*MM*-*DD*T*hh*:*mm*:*ss.sss*Z
```
Since this string starts with `YYYY-MM-DD`, it is safe to perform a lexicographical comparison with another string in a similar format. This is why we want to convert the input string \$d\$ to `YYYY-MM-DD` rather than converting our computed date to the input string format `DD.MM.YYYY` (which cannot be sorted lexicographically):
```
d.split`.`.reverse().join`-`
```
Before each recursive call, we increment the final result if `D.getDay()` is neither \$0\$ (Sunday) nor \$6\$ (Saturday), i.e. if it's not congruent to \$0\$ modulo \$6\$:
```
(D.getDay() % 6 > 0) + f(d, n + 864e5)
```
We add \$86,400,000\$ milliseconds to \$n\$ to reach the next day.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 24 bytes
```
46tQZt24&YO:Z':X-9XO83-z
```
[Try it online!](https://tio.run/##y00syfn/38SsJDCqxMhELdLfKkrdKkLXMsLfwli36v9/dUMzPUMDPSMDQwt1AA)
> 
> I don't want to have any input format so that specific code golf languages got a big advantage
> 
> 
> 
You half succeeded :-)
### Explanation
```
46      % Push 46 (ASCII for '.')
tQ      % Duplicate, add 1: gives 47 (ASCII for '/')
Zt      % Implicit input. Replace '.' by '/' in the input string
24&YO   % Convert string with date format 24 ('dd/mm/yyyy') to serial date number.
        % This is an integer representing day starting at Jan-1-0000
:       % Inclusive range from 1 to that
Z'      % Push current date and time as a serial number. Integer part is day;
        % decimal part represents time of the day
:       % Inclusive range from 1 to that
X-      % Set difference. Gives serial numbers of days after today, up to input
9XO     % Convert each number to date format 9, which is a letter for each day
        % of the week: 'M', 'T', 'W', 'T', ' F', 'S', 'S'
83-     % Subtract 83 (ASCII for 'S')
z       % Number of nonzeros. Implicit display
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~64~~ 56 bytes
```
DayCount[Today,""<>#~StringTake~{{4,6},3,-4},"Weekday"]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78H1CUmVcS/d8lsdI5vxTICslPSazUUVKysVOuCy4BSqaHJGan1lVXm@iY1eoY6@ia1OoohaemZgOVKcWq/VdwUFAyNtQzNNIzMjC0UIr9DwA "Wolfram Language (Mathematica) – Try It Online")
`DayCount[x,y,"Weekday"]` counts the number of weekdays between `x` and `y`.
The inputs `x` and `y` can be many things, including a fancy `DateObject` like the one returned by `Today`, or a string in the format (unfortunately) `mm.dd.yyyy`. 
My previous attempt tried to turn the `dd.mm.yyyy` input into a `DateObject` by telling Mathematica how to parse it; the new solution simply rearranges the string to put day and month in the order Mathematica expects.
It's worth noting that the 28-byte solution `DayCount[Today,#,"Weekday"]&` not only works perfectly for a month-day-year input format, but also correctly handles *unambiguous* day-month-year inputs such as `31.12.2018`, which couldn't possibly mean "the 12th day of the 31st month". So it's correct more than 60% of the time :)
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 61 bytes
```
{+grep 6>*.day-of-week,Date.today^..Date.new(|[R,] m:g/\d+/)}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/Wju9KLVAwcxOSy8lsVI3P023PDU1W8clsSRVryQfKBSnpwfm5KWWa9REB@nEKuRapevHpGjra9b@L06sVEjTUInXVEjLL1KwMbDQMzTQMzIwtFAwNtQzNIIwDYz1DAyBTCMDO@v/AA "Perl 6 – Try It Online")
[Answer]
# R, 72 chars
A variation on the answer provided by @ngm which avoids the grepl to save a few characters and works in non-English locales. 
`sum(strftime(seq(Sys.Date(),as.Date(scan(,""),"%d.%m.%Y"),1),'%u')<6)+1`
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), 174 166 165 bytes
With a bit of inspiration from Kevin's answer and a good ol' trawl through the deprecated Date API, I've managed to get a more succinct Java solution.
*-8 bytes thanks to Kevin's inventive regex date parsing*
*-1 bytes thanks to Nevay's clever bitwise operation*
```
import java.util.*;d->{long r=0,s=new Date().getTime(),e=Date.parse(d.replaceAll("(..).(..).","$2/$1/"));for(;s<=e;s+=864e5)r-=-new Date(s).getDay()%6>>-1;return r;}
```
[Try it online!](https://tio.run/##jZBRa8IwFIXf@ysuZYNk2jSRKUpWYeAeJwP3NvYQ2@ji2qQkqU6kv71LnexlMIRwuTl8ufec7MReJKaWeld8dqqqjfWwCxppvCrJHQdIU3gRQTUb8B8S1kcvk9w02gMasBmO8lI4B89C6VMEoLSXdiNyCcv@ClAavYUcrbxVoSlwGGLNwcHTVy5rr4zmAWujUJwXXuWwBA0ZdEUyP53f2owOXablARbCS4TJVvpXVYVuKLNeIrWwTqKCWFmXYfNjWaIYEYLJucTD@GaU3rA0xphvjEXcPWSSu0E2ndzLMbZJlvxOd@fxC3FE@HYynyeMW@kbq8HytuO9y7pZl8HlxezeqAKqkP0S8O0dxN@IPz@xOjovK2IaT@rA@lIjTXIU0ymhMzKibNo7/B8dE0avQ9nkapQyEs6IUXpB26jtvgE "Java (OpenJDK 8) – Try It Online")
**Explanation**
```
import java.util.*;                         // Required import for Date 
long r=0,                                   // Initialise result variable
     s=new Date().getTime(),                // Current date in millis
     e=Date.parse(
         d.replaceAll("(..).(..).","$2/$1/")// Use regex to convert to MM/dd/yyyy
     );                                     // Parse date arg using deprecated API
for(;s<=e;                                  // Loop while current millis are less than date arg (e.g. date is before)       
    s+=864e5)                               // Add 86400000 ms to current date (equiv of 1 day)
    r-=-new Date(s).getDay()%6>>-1;        // If day is Sunday (0) or Saturday (6) don't increment, else add 1
return r;                                   // When loop finished return result
```
[Answer]
# [Red](http://www.red-lang.org), 72 bytes
```
func[a][b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]
```
[Try it online!](https://tio.run/##HcvBCoQgFEbh/TzFvx8iLYiQeYq2FxeaV5DCiTSkpzdp@XE4J7u6sCP98ar6K65kNFmF@C@9M5mRFASumMNOwcP2hXlz5sYPE7WW8IXUprFN9kXS9ThDzPAYZSdFNwg51wc "Red – Try It Online\"")
Takes the date in format dd-mm-yyyy, for example 31-10-2018 (also works with 10-Oct-2018)
## Strict input:
# [Red](http://www.red-lang.org), 97 bytes
```
func[a][a: do replace/all a".""-"b: now/date s: 0 until[if b/weekday < 6[s: s + 1]a < b: b + 1]s]
```
[Try it online!](https://tio.run/##HctBCsMgEEbhfU/xM9tSoy2UIj1FtuJijCNIxYSYEHp6G7r8eLxVYh8lOn9Jtqe9To69Y4s4Y5Wl8CQDlwImRXSjYFHnY4i8CZqFxl63XFxOCMMh8on8xRtPd7aGK4znk@cU/mi@L2uuGxLoYZTR6q7Ni/oP "Red – Try It Online")
## Bonus:
Returns a list of the dates/weekdays of the working days up to the given date:
# [Red](http://www.red-lang.org), 235 bytes
```
f: func [ a ] [
    b: now/date
    d: system/locale/days
    collect [ 
        until [ 
            if b/weekday < 6 [ 
                keep/only reduce [ b ":" d/(b/weekday) ]
            ]
            a < b: b + 1
        ]
    ]
]
```
[Try it online!](https://tio.run/##XY5BCoMwEEX3OcXHVUuRaAulhJ6iW8kiJhMQ00Q0Ip4@jS5K7dv9@fOGGcmkF5lGsmQF7Ow1GihINAyZVsCHhRsVac9GYFqnSG/uglaOcrNOe6ODc6Rjtve4MfvYud/BRmfR8oWozyaeuP/3Gz3RwIN3K0Yys6a806IQBQw/feUz5EE8JpVv5@dbXFCz44pkMg1j5yMsbnVZV@W1qh/pAw "Red – Try It Online")
[Answer]
# JavaScript, ~~87~~ 85 bytes
Returns `false` for `0`.
```
s=>([d,m,y]=s.split`.`,g=_=>new Date<(x=new Date(y,~-m,d--))&&(x.getDay()%6>0)+g())()
```
[Try it online](https://tio.run/##NcYxDsIgFADQq5gmNv9HIMWhcfAz9RbGWFIoqaHQCNGyeHWcfNN76rdO02vZMg/R2DpTTaTgZtjKyp2SSJtf8ihG5uhBKtjPYdDZXmGn/6GwL1@Z4RyxbWEXzuZBF8Bjrzo8OUAErFMMKXorfHQwQyN7ITtx7uSlQaw/) or [check the next 31 days](https://tio.run/##RY69asMwFEZfxUMa7q2li/sXSokcCpk6tEPHJETCUoyDLRlJpDIhfXXXQ0K3A@fj4xzVSYXKN33k1mkzHsQYRAkbzTo27ESg0LdNlCRZLfaitOYnW6tolpDEjWFgv7xjmnPE@RwS1Sau1QB4tygLzGtABBwrZ4NrDbWuhg0RvXs/bZ4ecUed6gH2LKEo5eys/4/zG@Wvi2fzcp@Qovv4/voEpNA2lYGCPRR4beSSvDkZH8ykj66xU/UlE9nsnFYH0Pgmo9NqkBd51VsrcfwD)
[Answer]
# [Python 2](https://docs.python.org/2/), ~~163~~ ~~156~~ ~~149~~ 147 bytes
```
lambda s:sum((date.today()+timedelta(x)).weekday()<5for x in range((date(*map(int,(s.split(".")[::-1])))-date.today()).days))
from datetime import*
```
[Try it online!](https://tio.run/##TY3LCsIwEEX3fkXIaqbaYAqCFP0SdRFposHmQTLF9utjqhtXF@7j3LjQM/iumPO1jMrdB8VynycHMCjSgsKgFsAtWacHPZKCGVG8tX59/dPBhMRmZj1Lyj/0bwWNUxGspx1kkeNoCbjgeOn7Vt4Qsf1Ho6iSETcmBcfWZP1i1sWQqCkxVQ4zlRYnqu3CpZBSdHt55B8 "Python 2 – Try It Online")
-7 with thanks to @mypetlion
-7 more with thanks to @ovs
+30 due to the very restrictive input format which I only noticed just before I posted my previous code which took input as e.g. `(2018,11,1)` :-(
[Answer]
# [Java (JDK 10)](http://jdk.java.net/), 171 bytes
```
s->{int c=0;for(var t=java.time.LocalDate.now();!t.parse(s.replaceAll("(..).(..).(.*)","$3-$2-$1")).equals(t);t=t.plusDays(1))c-=t.getDayOfWeek().getValue()/6-1;return c;}
```
[Try it online!](https://tio.run/##bVFdS8MwFH3fr7iGDZKxxrbikNUOBkMQFB8m@iA@xC4d2dK0JreTIf3tM23HXibkg3PuyT05yVbsRbBd746qqEqLsPWY16g0HyeDCy6vTYaqNG0x08I5eBbKwO8AoKq/tMrAoUC/7Uu1hsLX6AqtMpuPTxB241gnBXgtHw0@nJrd95I55JAeXTD/VQYhS8MkLy3dCwuYdjdAVUj@VGZCLwVKbsofypIr5JWwTlLHray0yORCa0oo54yfljEjEzK8CYZxMIwIY1x@10I7iizB1B/XtVuKg6MRY1ngiY1Ej1/ydyl3lLXwTehaUnY9DaLESqytgSxpjkmX5RwQpUMH6SkiAAljHoU8DqM7Mjlzt5dcNP1HF3E/4igMSUc1vVn7JL1hZzfrTdnZc3VwKAte1j6XV2FOycjNYLQeGTLpxBPIuagqfVg4/we0pRjrmzeDdjbHPw "Java (JDK 10) – Try It Online")
## Credits
* -4 bytes thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~168~~ ~~160~~ ~~139~~ 133 bytes
*35 bytes less thanks to [Quintec](https://codegolf.stackexchange.com/users/20438/quintec) and [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)*
```
D=>{var i=D.split('.'),n=0;for(var d=new Date();d<=new Date(i[2],i[1]-1,i[0]);d.setDate(d.getDate()+1))n+=-~d.getDay()%7>1;return n;}
```
[Try it online!](https://tio.run/##RcnPCoMgHAfwV@ky9Ecp2mEbODv1FtFB0sIRGuoaY2yv7toIdvr@@VzVquIQ7JKI89rkUeZWNs9VhcLKlsZltgkjiqBykonRB/wlLZ25F61KBoPQl/@yXd1XtuM94VuwflMaTfqZptPeoOQArpTkvX8PDIdTw0Uw6RZc4cQrD95FPxs6@wmPGPEj5YzWjJ8RgMgf "JavaScript (Node.js) – Try It Online")
```
D=>{
  var i=D.split('.'),                 // Splits the date string by .
      n=0;                            // Counter variable
  for(var d=new Date();               // For the actual date
      d<=new Date(i[2],i[1]-1,i[0]);      // As long as the date is less or equal the requested date
      d.setDate(d.getDate()+1))           // Count the date one up
    n+=-~d.getDay()%7>1;                // If the date is not a Sunday or Saturday
  return n;                           // Return the counter variable
}
```
[Answer]
# [Python3](https://docs.python.org/3/) & [Numpy](http://www.numpy.org/), 96 bytes
I couldn't get smaller than the boring pre-made solution...
```
from numpy import*
d=datetime64
lambda s:busday_count(d('today'),d(f'{s[6:]}-{s[3:5]}-{s[:2]}'))
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P60oP1chrzS3oFIhM7cgv6hEiyvFNiWxJLUkMzfVzIQrJzE3KSVRodgqqbQ4JbEyPjm/NK9EI0VDvSQfyFXX1EnRSFOvLo42s4qt1QXSxlamEIaVUWytuqbm//8A "Python 3 – Try It Online")
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~107~~ 99 bytes
*-8 bytes thanks to mazzy*
```
$d,$m,$y=$args-split'\.';for($a=date;$a-lt(date "$y-$m-$d");$a=$a|% *ys 1){$o+=($a|% D*k)-in1..5}$o
```
[Try it online!](https://tio.run/##HcvRCsIgAEbhV5Hxh7pNmUERDO96jG4ErUYuhwpDqme31d3hg7OE1cV0d97XCttj7lE0TLwlkRY/ZXqRdLyGyGC0NdmNMMJn9kvSoAjMArbhG2/Xe0fakojiL4ROsz@c2wcX01NJefgg1FqpOko1yP2gTvQL "PowerShell – Try It Online")
Performs a regex `-split` on the input `$args`, stores the values into `$d`ays, `$m`onths, and `$y`ears, respectively. Then, enters a `for` loop, initializing `$a` to today's date. The loop continues while `$a` is `-l`ess`t`han our input target date. Each iteration we're adding `1` da`ys` to `$a`, and checking whether the current `D*k` (short for `DayOfWeek`) is in the range `1..5` (i.e., Monday to Friday). That Boolean result is accumulated into `$o` and once we're out of the loop that value is left on the pipeline and output is implicit.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~147~~ ~~143~~ ~~141~~ 140 bytes
```
from datetime import*
lambda e,s=date.today():sum((s+timedelta(x+1)).weekday()<5for x in range((date(*map(int,e.split(".")[::-1]))-s).days))
```
[Try it online!](https://tio.run/##nZPdjtMwEIWvm6cYBVWyd7NW3KUCKgrPgapeuMmEWiS25Zkq26cvdlqgIBak3FnjOf7O/Dic@ejd6nLpoh@gNYxsBwQ7BB/5oejNcGgNYEXbfKfYt@Ys5IZOgxD0mHNb7NmIl0ctpRoRv00JH9edj/AC1kE07isKkeXiYTBBWMcVKgq9ZVGqUu42mye9l/KJpEpikvLCSEzbXbEQPxwp50ch74A5c7tOTOLY5bAol61aDmr5pZTVf5VvZyufZytXs5V6trKez/xHi94ABWxsZxvIo4LGEAIfDcNoKA@djwgtUhNtYOtdgpX6ndIrtar1@7L6uWgZEK4AXf@6v6OpaXHklTpmxNGEgC5hOhgR4inTLIF3YCAvILr2M4gQ/cEc@jP4E4PvgBofUGYja5VQr/t4rlX94XUfxb4o8m5PdedK86purubQAbGJPD0LydOtS9gWi@S2Rydy@q7eS/gEOqkWIabvALdodT3odOjEn7HkHXvC30V3FUxD/PvAbq/Jy3c "Python 2 – Try It Online")
Takes a string, e, which represents the end date in the format "dd.MM.YYYY". Optionally also takes the start date, but this is expected to be a datetime.date.
The start date, s, is defaulted to today's date as a datetime.date object in order to disregard time. The end time is parsed into a datetime.datetime object then converted to a date, since datetime.date objects do not have a parse method and datetimes cannot be added to/subtracted from dates. Iterates through every day in (start, end] and adds 1 to the total if its weekday number is < 5. ([0-4] are [Mon-Fri], [5-6] are [Sat-Sun]).
Datetime parsing is the worst, you guys.
EDIT: Stole [ElPedro](https://codegolf.stackexchange.com/a/173117/73368)'s map(int,thing) trick to save 4 bytes.
EDIT 2: ELECTRIC BOOGALOO: Saved 2 bytes by making it an anonymous function. (Thanks Aaron!)
EDIT 3: xrange -> range. (Thanks again Aaron!)
[Answer]
# PHP (with [Carbon](https://carbon.nesbot.com/docs/)), 107 bytes
```
function a($d){return Carbon\Carbon::parse($d)->diffInDaysFiltered(function($e){return!$e->isWeekend();});}
```
[Answer]
# [K4](http://kx.com/download/), 40 bytes
**Solution:**
```
{+/1<.q.mod[d+!(."."/:|"."\:x)-d:.z.d]7}
```
**Explanation:**
Calculate the difference between the dates, use modulo 7 to ignore weekends, sum up.
```
{+/1<.q.mod[d+!(."."/:|"."\:x)-d:.z.d]7} / the solution
     .q.mod[                         ]7  / modulo with 7
                                 .z.d    / UTC date
                               d:        / save as d
                              -          / subtract from
               (             )           / do this together
                       "."\:x            / split input on "."
                      |                  / reverse
                 "."/:                   / join back with "."
                .                        / take the value
              !                          / range 0..the difference
            d+                           / add today's date to range
   1<                                    / is 1 less than the modulo (ie is this mon-fri)?
 +/                                      / sum up
```
**Notes:**
* same byte alternative to the date parsing: `"D"$,/|"."\:x`
[Answer]
# PHP, 66 bytes
```
for($t=time();$t<strtotime($argn);)$r+=date(N,$t+=86400)<6;echo$r;
```
empty output for `0`; insert `+` between `echo` and `$r` to fix.
Run as pipe with `-nr` or [try it online](http://sandbox.onlinephpfunctions.com/code/f75fa3bef0bf297b428c74ae7583b55fff543da6).
---
60 bytes with unary output:
```
for($t=time();$t<strtotime($argn);)echo date(N,$t+=86400)<6;
```
[Answer]
# q, 52 79 bytes
```
{x:"D"$"."sv reverse"."vs x;i:0;while[x-.z.d;$[2>x mod 7;x-:1;[i+:1;x-:1]]];:i}
```
in q, each date has an underlying integer value, based on how many days have passed since the start of the millenium. Applying 'mod 7' to this, you get unique values for each day of the week (0 for Saturday, 6 for Friday). So when 2 > x mod 7, don't increment the counter, to avoid counting weekends.
EDIT: Missed strict date format, editing
EDIT2: Included
[Answer]
# IBM/Lotus Notes Formula - 99 bytes
```
d:=i;c:=0;@While(d>@Today;@Set("c";c+@If(@Weekday(d)=1:7;0;1));@Set("d";@Adjust(d;0;0;-1;0;0;0)));c
```
Takes input from a date/time field `i`. The input format of `i` is set to `.` separated so there is no need to convert the input. Notes can take a date input with any separator as long as you tell it before what it is going to be (hope that's not cheating!). Formula is in computed numeric field `o` on the same form.
Interesting aside: Ever since `@For` and `@While` were introduced into the Formula language in (I think) R6 by the great [Damien Katz](http://www.damienkatz.net/2005/01/formula-engine-rewrite.html "Damien Katz") the only use I have found for them is code golfing. I have never used them in a production app.
There is no TIO available for formula so here is a screenshot taken on 02.10.2018:
[![enter image description here](https://i.stack.imgur.com/6wIz1.png)](https://i.stack.imgur.com/6wIz1.png)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 81 bytes
```
->e{require'date';(Date.today...Date.strptime(e,'%d.%m.%Y')).count{|d|6>d.cwday}}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y61uii1sDSzKFU9JbEkVd1awwVI6ZXkpyRW6unpgTnFJUUFJZm5qRqpOuqqKXqquXqqkeqamnrJ@aV5JdU1KTVmdil6yeVAHbW1/wsU0qLVjUz0DI30jAwMLdRj//8HAA "Ruby – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~209~~ ~~208~~ 205 bytes
Compiler flags `-DU=u=localtime(&b)` `-DW=tm_wday` `-DY=tm_year` `-DT=tm_yday` (52 bytes).
```
#import<time.h>
i;f(char*a){long b;struct tm t,*u;time(&b);U;strptime(a,"%d.%m.%Y",&t);for(i=0;u->T^t.T|u->Y^t.Y;u->W&&u->W^6&&i++,b+=86400,U);return i;}
```
[Try it online!](https://tio.run/##bY9va4MwEIdfr59CHAZTY4hlSCGzr/YRlCKMjhj/NGCipOdG6frV56Kj7wbH8dzvHjhOxrIXppvnZ6XHwcIrKN3Q82GjeBvKs7BbgW/9YDqv4hewkwQPtAdkO/HFDFGFebFsxnUUxA9qGmgalD5BgHk72FBljE/xIT8Bzb8dlA7KJTkitPRTipCKIlJF2T59YYwUmNsGJms8xe@zMuBpoUz4Oaga3zZPo3VRG7pL78YnDpKUJozuWLL3Meb/CCyhrnYJY6twn39k24vuMsdvxwz0x1ctro7Lha@NsI7zlf/yIpuyfpCif7z8Cw "C (clang) – Try It Online")
-1 byte thanks to @JonathanFrech
[Answer]
# [Scala](https://www.scala-lang.org/), 251 bytes
Port of [@Olivier Grégoire's Java answer](https://codegolf.stackexchange.com/a/173176/110802) in Scala.
---
Golfed version. [Try it online!](https://tio.run/##bVBdS8MwFH3vr7gWhAQlNHtQWak4XAdDpuAEEZER27sto0tLct0mo7@9poWJTkMI4XzlnrhMFarR66q0BCu1UeKDdCFmwU@IcEdi6pECh4pwVNq1oiAo31eYEUyUNuAVaHIHg6qCfQBAVmmC@@4OcENLW27da7rLsCJdmrcOznEOGcv7MCWrzYL3YWzIM3Xgj40qwPR9RAIGt11U0BwcB4PXJ/uNsmCTKG4dLrlVhZ9EWbFAGhtHymQYO@GQnvQaWZvVluCdHP@X4y/5cXMW5rmYTMSnXyEXlbIOWc55vF3qAtkJc6DmhBaQ872eM9dms@@HhoOX2cNo9pymd/z08lpye5ZIP6HK8z@il3TweC55Hdu6OXxM5atTYZgRGQvlhZCR6EXyKuT8mIyk8Lsno6gl66D5Ag)
```
def c(d:String):Int={var r=0;val s=Calendar.getInstance;s.setTime(new Date);val e=Calendar.getInstance;e.setTime(new SimpleDateFormat("dd.MM.yyyy").parse(d));while(!(s after e)){if(s.get(Calendar.DAY_OF_WEEK)%7>1)r+=1;s.add(Calendar.DAY_OF_YEAR,1)};r}
```
Ungolfed version. [Try it online!](https://tio.run/##hVBtS8MwEP7eX3EWhAQltPugMpg43AZDpuAEGSIjNrctI0tLcm6K7LfXtM6yqWAoSe@el3vxmTSyLPWqyB3BUq6leCVtxDTaTxG@kRiHjMGeJBzkbiUpivKXJWYEI6ktBAZa5aFbFPARAZCTmuC2/ge4ooXLN/6p/5ZhQTq3z3Va4QwyptowJqftnLdhaCkg2yhca2nAtoNFByxuGqs/NYHzhVYyBy7ESRMb8CG@liY0KJ2YIw2tJ2kzZHxH8sIjPegVsqpUNSPjfM8A/zPAA4Ofq2KxUmI0Eu/hxFwU0nlkqqmwWWiDwI68kDNCx5DzZhwAPQPmq6Ks6aDXnUzvBtPHfv@GwzGcwyWkPEx90oG00QU3pX5pJv3u/Wlg72jb3eui76jefRFWS8YyKzIWp2ciTUQrSS/iuuUDMElF@FppklTgNirLTw)
```
import java.util._
import java.text.SimpleDateFormat
object Main extends App {
  trait N {
    @throws[Exception]
    def c(d: String): Int
  }
  val n: N = new N {
    def c(d: String): Int = {
      var r = 0
      val s = Calendar.getInstance()
      s.setTime(new Date())
      val e = Calendar.getInstance()
      e.setTime(new SimpleDateFormat("dd.MM.yyyy").parse(d))
      while (!s.after(e)) {
        if (s.get(Calendar.DAY_OF_WEEK) % 7 > 1) r += 1
        s.add(Calendar.DAY_OF_YEAR, 1)
      }
      r
    }
  }
  println(n.c("16.10.2018"))
  println(n.c("01.01.2100"))
}
```
]