I'm trying to convert a personnel's date of birth to their actual age within a ViewModel inside of another viewmodel I plan on calling in the front end. I've managed to create public DateTime? PersonnelDOB { get; set; }  and it's bringing back their Date of Birth I.E 6/12/1972 I need to convert this to their actual age so instead of 6/12/1972, it'll be &quot;48 years old&quot; the issue to this current problem is that 'dob' is a DateTime and 'today.year' is an int. I can't subtract a DateTime from an int. I need to also make sure I account for leapyears and for it to actually accurately output their age. I also will want to check that dob isn't null. I dont have to do this within a viewmodel I created, it was just an avenue I was exploring. Thank you all for your help! public DateTime? PersonnelDOB { get; set; }          public PersonnelDOBViewModel()     {         var dob = PersonnelDOB;          // Save today's date.         var today = DateTime.Today;          // Calculate the age.         var age = today.Year - dob;          // Go back to the year the person was born in case of a leap year         if (dob &gt; today.AddYears(-age)) age--;         return age;     }  ** A coworker helped me out and for those of you interested in the right answer - here it is public DateTime? PersonnelDOB { get; set; }      public int? PersonnelAge     {         get         {             if (!PersonnelDOB.HasValue)                 return null;                          DateTime today = DateTime.Today;                          int years = today.Year - PersonnelDOB.Value.Year;              years -= (today.Month &lt; PersonnelDOB.Value.Month || (today.Month == PersonnelDOB.Value.Month &amp;&amp; today.Day &lt; PersonnelDOB.Value.Day)) ? 1 : 0;             return years;         }     }
Given a DateTime representing a person's birthday, how do I calculate their age in years?
Take the square $[0,1]^2$ we take $n$ random lines through the square. You can choose random lines by choosing a point on one of the sides of the squares and randomly choosing a different point on any of the other three sides and then drawing a line connecting them.   What is the probability that after $n$ of these random lines the largest region is greater than or equal to $0.5$?  Any tips or cases help, thanks. Touch enabled monitors and Android I've been using Ubuntu for a few years now, but I just installed Version 16.04, and I've been having a lot of issues. I'm not a command line expert, but I tried to install some software last night, and it is creating issues (and also not working properly).   When I run sudo apt-get -f install, I see the following message:  Reading package lists... Done Building dependency tree        Reading state information... Done Correcting dependencies... Done The following additional packages will be installed:   lua-event lua-expat lua-filesystem lua-sec lua-socket lua5.1 prosody Suggested packages:   lua-zlib lua-dbi-postgresql lua-dbi-mysql lua-dbi-sqlite3 The following packages will be REMOVED:   jitsi-meet-tokens The following NEW packages will be installed:   lua-event lua-expat lua-filesystem lua-sec lua-socket lua5.1 prosody 0 upgraded, 7 newly installed, 1 to remove and 22 not upgraded. 3 not fully installed or removed. Need to get 0 B/413 kB of archives. After this operation, 2,296 kB of additional disk space will be used. Do you want to continue? [Y/n] Y (Reading database ... 176266 files and directories currently installed.) Removing jitsi-meet-tokens (1.0.962-1) ... dpkg: error processing package jitsi-meet-tokens (--remove):  subprocess installed post-removal script returned error exit status 10 Errors were encountered while processing:  jitsi-meet-tokens E: Sub-process /usr/bin/dpkg returned an error code (1)   Can someone help me figure out what I need to do to get this resolved? I'm fine with deleting jitsi, but I'm not sure if that will correct the problem.   Currently there is a red circle with a line through it in the upper right corner that indicates there may be installed packages with unmet dependencies. Does $\pi$ contain all possible number combinations? Limit FTP access only to the /var/www with vsftpd I am running vsftpd as ftp server on my linux (rasbian), I log in to the machine as a root user.  I would like to be still locked to using only /var/www, how can I configure vsftpd conf to accomplish it? regex error - nothing to repeat Redirecting stdout to a file you don't have write permission on When you attempt to modify a file without having write permissions on it, you get an error:  &gt; touch /tmp/foo &amp;&amp; sudo chown root /tmp/foo &gt; echo test &gt; /tmp/foo zsh: permission denied: /tmp/foo   Sudoing doesn't help, because it runs the command as root, but the shell handles redirecting stdout and opens the file as you anyway:  &gt; sudo echo test &gt; /tmp/foo zsh: permission denied: /tmp/foo   Is there an easy way to redirect stdout to a file you don't have permission to write to, besides opening a shell as root and manipulating the file that way?  &gt; sudo su # echo test &gt; /tmp/foo Newton's cradle Why, when one releases 2 balls in , two balls on the opposite side bounce out at approximately the same speed as the 1st pair, rather than one ball at higher speed, or 3 balls at lower speed? Where does the extra kinetic energy come from in a gravitational slingshot? I read in  in this site that the KE a free-falling ball acquires is not originated by the attracting body but that energy was actually stored in the ball when it had been lifted to the height it dropped from.  In this way, it was said, gravity is subject to the conservation of energy principle and cannot change the total energy of an object.  Consider now the maneuver known as a  (also gravity assist) used by space probes such as the . A space probe approaches a planet with velocity $v$, slingshots around, and ends up with velocity $v+2U$, where $U$ is the velocity of the planet.  Consider the energy of the probe. Before, it was $E_i=\frac{1}{2} mv^2$ and after it is $E_f=\frac{1}{2} m(v+2U)^2$. It looks like $E_f$ is much bigger than $E_i$ - but where did the additional energy come from?   Is this not a violation of the conservation of energy principle? Find the set of $n\in\Bbb Z^+$ with $M=\{n,n+1,n+2,n+3,n+4,n+5\}$ partitionable into two sets Find the set of all positive integers $n$ with the property that the set $M=\{n, n + 1,n + 2,n + 3,n + 4,n + 5\}$ can be partitioned into two sets such that the product of the numbers in one set equals the product of the numbers in the other set.   If $n=1$ them $M=\{1,2,3,4,5,6\}$ and there is no such partition, so $n \ge 2$.  If the prime $p|n$ then either $p|2$ or $p|3$ or $p|5$ which means either $p=2$ or $p=3$ or $p=5$.  Suppose $n=2k$. Then $M=\{2k, 2k + 1,2k + 2,2k + 3,2k + 4,2k + 5\}$. I have no idea how to proceed. Compton scattering vs. photoelectric effect Say a photon hits some atom.  What determines whether there will be a photoelectric effect (photon is absorbed, electron is released) or whether there will be a Compton scattering (the photon is  scattered at some angle, and the electron is released with another direction)? How to prove $n^5 - n$ is divisible by $30$ without reduction How can I prove that prove $n^5 - n$ is divisible by $30$? I took $n^5 - n$ and got $n(n-1)(n+1)(n^2+1)$ Now, $n(n-1)(n+1)$ is divisible by $6$. Next I need to show that $n(n-1)(n+1)(n^2+1)$ is divisible by $5$. My guess is using Fermat's little theorem but I don't know how. It seems I put a   Bounty assigned by outside party, two lengthy, reference-citing answers, one "-1" (awarded the bounty), one "-2", two others scored "0" and "-2" respectively, the answers suggesting one or the other is correct, 73 comments and no consensus so far - and me, as the asker, lost without a clue what to think of the answers anymore -  this is no longer "Learners' Level" question, so I thought I'd bring it here and hear what the experts have to say.    Original question:  Plurality of verb depending on plurality of list elements  An edit was suggested to my sentence.     There was were an orange, some grapes, two apples and a small pile of cherries on the plate.   In my native language plurality of the verb always follows plurality of the first element on the list. There were an orange,... sounds awkward to me, no matter what follows up. My simple solution was reordering:     There were some grapes, an orange, two apples and a small pile of cherries on the plate.   But that's not the first time I faced this situation and I'd like to know what the rules of grammar say about that - was my editor overzealous or am I trying to copy rules of my language that don't apply in English?    Someone linked a  for negatives, where the situation is more clear-cut ("There is no..."). Same applies to connection with "or" apparently, per accepted answer there. Still, nothing for "and".  It seems there is a consensus that in that if the verb goes after the list, it will be plural.     an orange, some grapes, two apples and a small pile of cherries were on the plate.   There doesn't seem to be clear consensus for:     On the plate { was | were } an orange, some grapes, two apples and a small pile of cherries   Adding more to the confusion is the abbreviated form: "There's"     One last note. In North America, at least, there is a widespread use of using a singular form like "there is" and "there was", without regard for the subject item or items, and this "there is" is often shortened to "there's":           There's three apples on the table!      Could you please clarify this mess? Converting case of all values in all fields of table using ArcPy & Python? Processing time/speed for Mosaic to New Raster I have a question on speeding up “Mosaic to New Raster” or finding an alternative.  After completing a suitability analysis we are trying to define movement corridors.  We used a modified CircuitScape that left 4 folders, each containing 1080 raster tiles across our study area.  We now need combine all 1080 rasters in each folder then combine these 4 combined rasters into a final raster which will be analyzed for paths.  I tried a python script that just wouldn’t work so I went on to Model Builder.  It iterates through the grids in the folder, collects the values (raster names), then mosaics all to a new raster.  It has been running for 5 days now and the results window indicates it is working.  I’m hoping it will conclude in the next day or 2.  But, we still have 3 more folders, each with 1080 rasters, that need to be mosaicked.  So….is there a way to speed up Mosaic to New Raster or is there an alternative I could use to produce the final grid?    The cell size is 270 meters, 540 x 540 columns and rows, 1 band, 32 bit floating. Should I say "She is in the park" or "She is at the park"? I am really confused.  Which preposition is correct?     She is in/at the park.   They are in/at the park.   I am in/at the park.   Should I use in or at in these sentences? Recursive bash script to collect information about each file in a directory structure How do I work recursively through a directory tree and execute a specific command on each file, and output the path, filename, extension, filesize and some other specific text to a single file in bash. There is some behavior I can't understand in the Unity Desktop.   Open nautilus via. clicking in the launcher onto the home-button Navigate to for example the windows-partition in nautilus Minimize nautilus Click on nautilus in the launcher doesn't open the nautilus with windows-partition, instead it opens a new window with the home folder.   Is there a workaround for this strange behavior?  Regards, Arthur Which tools and technologies are used to build the Stack Exchange Network? Difference between "theoretical computer science" and (beta) "computer science" Possible Duplicate:          Title says it all. From what I can see, "theoretical computer science" questions seem to be slightly more isolated to discussing algorithms, whereas "computer science" seems to have questions that are slightly broader and higher-level. Is there any place on the Stack Exchange sites where they give a longer description?  I'm just curious as to what niche the beta "computer science" site is meant to fill, as I see many topics in both forums that overlap.