I want to get difference between two dates using the datediff and i want to exclude the weekends.The Code below.  SqlDataAdapter sda = new SqlDataAdapter("SELECT [uSerial] " +", DATEDIFF(dd,[RestartDate],getDate()) as statusDuration ,[cutRefs] " "FROM [dbo].[tblFTTH_Fault_Tool]", conn); DataTable ds = new DataTable(); sda.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind();   kindly assist.
How can I calculate the number of work days between two dates in SQL Server?   Monday to Friday and it must be T-SQL.
Occasionally (very occasionally) when returning to the main page of a site by clicking on the logo I get the following message:     It was not possible to perform this tag search at this time due to an unexpected error.   This is odd because I'm not performing a tag search.  So far this has happened on both Movies &amp; TV and Cooking.  I have heard that others are getting this same message. Screen Resolution Problem with Ubuntu 14.04 and VirtualBox Looking for a sci-fi movie in which a human astronaut befriends an alien on a reddish planet This probably wasn't a blockbuster back in its time as I remember the special effects didn't seem all that bombastic, but I do remember a few details.  A human astronaut lands (or crash-lands) on a prominently reddish planet. It might have been Mars, thought it might not have been. I think the atmosphere on said planet was humanly breathable (as in the astronaut does not wear his helmet).  This human astronaut needs to survive. He spots a humanoid alien, apparently also having crash-landed or otherwise in need of survival. He sees this alien consume some sort of greenish orb, apparently for nourishment. He sneaks up to the alien (or the alien craft) in an attempt to grab some of those greenish orbs. I don't remember whether he succeeds, but he does get beaten up by the alien.  The next bit of detail I remember was the human astronaut constructing some sort of shelter to protect both him and the alien from... meteor showers? The human astronaut piles up some rocks to build a hut while the alien, apparently having learned a few English words, says "shiiiiit" and "no solid". The human astronaut asks, incredulous, "No solid?" and punches the hut he just build. "See? Solid!" he proclaims, while the hut collapses a few seconds later. The alien laughs.  Later on the human astronaut is either caught by or accidentally fell into some sort of mouth-in-the-sand creature. He is saved by the alien in the process (or was it the alien who fell into the mouth-creature and was saved by the human astronaut). They witness the mouth-creature spitting out a turtle-like shell (from another local wildlife) of some sort. The human astronaut observes, and I paraphrase, "This stuff must be so tough that even [the mouth-creature] cannot digest it!" He then proceeds to build a meteor shelter from collected shells.  The last bit of detail I remember is when the alien becomes pregnant and is dying. The human astronaut, having thoroughly befriended the alien at this point, asks (and I paraphrase), "What do you mean you're pregnant? Aren't you a male?" to which the alien responds (and again I paraphrase), "For us it comes naturally, unlike for you humans whose pregnancy only comes after a brief period of pleasure". The alien then asks the human astronaut to bring the child to the alien's home planet and recite the names of the child's ancestors in front of... alien rulers, I guess. The last scene of the movie is of the human astronaut, having arrived at the alien's home planet, standing side-by-side (or perhaps hand-in-hand) with the alien child while chanting in an alien language (what I presume to be the names of the child's ancestors). Why is a ConcurrentModificationException thrown and how to debug it How to change the catcode in a macro A potential customer wants to evaluate our storage system. They run Windows 2008R2 x64 with 4KB NTFS on a virtual test machine they've sent us. They did not seem to know this at hand, so I think it's reasonable to assume that environment was not tweaked. The tests are inserting, indexing, searching, deleting. Tool is not known to me.  Given that the windows NTFS block size is 4KB, and SQL write in 64KB chunks - is it safe to assume that a block size of 64k on the SAN is a good choice?  They run SQL Server 2008, perhaps standard. If $e^{itx_n}$ converges for every $t\in\mathbb R$, then does $x_n$ converge? Override a method via ObjC Category and call the default implementation? I would like the user to have full rights on this folder (as well as all sub-directories and files in it):  ~/.blabla   currently owned by root.  I have found numerous posts (in this forum and elsewhere) on how to do this for files but I can't find a way to do it for whole folders. Here the lower box dimension and the upper box dimension are exactly what Falconer talks about in his book "Fractal Geometry". I already know that the upper box dimension is finitely stable since $N_\delta(A\cup B)\le N_\delta (A)+N_\delta(B)$, where $N_\delta(A)$ is defined as usual, and Falconer gives an example to show the box dimension may not be countably stable. (We know that, however, the Hausdorff dimension is countably stable).  But now I want to find the example to show the lower box dimension may not even be finitely stable.It seems that we can use von Koch curve to illustrate this, but what is the explicit explanation for this? Since the lower box dimension is monotonic, we need to find set A and B and show that   $\underline{\dim}_B(A\cup B)&gt;\max\{\underline{\dim}_B(A),\underline{\dim}_B(B)\}$. What word could describe an operation of either importing or exporting?  X is to import and export as migration is to immigration and emigration.  Porting isn't the word I'm looking for, I don't think, but that's what I'm getting at. Cheers! Prove that $B[x] \cap B[x^{-1}]$ is integral over $B$ Hypernym for “import” and “export”? What word could describe an operation of either importing or exporting?  X is to import and export as migration is to immigration and emigration.  Porting isn't the word I'm looking for, I don't think, but that's what I'm getting at. Cheers! Can older cards that refer to a player/opponent ever be used on planeswalkers? Many older cards refer to players or opponents, e.g. "deal 3 damage to target player". Can any of these be used on planeswalkers, beyond the fact that you can simply attack them with creatures?  For example:   Would my opponent discard a card if  damaged a planeswalker they control? Would my opponent, the planeswalker, neither, or both amass poison counters from an unblocked ? Can  target a planeswalker? Does  affect planeswalkers? Can  prevent damage to a Planeswalker? Would  be obligated to take damage being dealt to a planeswalker? Can a planeswalker gain loyalty from ? Can  prevent damage to a planeswalker? How to select lines between two marker patterns which may occur multiple times with awk/sed Explanation of unpredictable behaviour of tee I encountered a behaviour that I don't understand while testing a script that sums the outputs from repeated executions of a program. To reproduce it create the text files out, which represents the output of my program, and sum, the file that holds the sum of the values returned on previous executions and which starts out as a copy of out,  cat &gt; out &lt;&lt; EOF 2 20 5 50 EOF cp out sum   The strange thing happens on running  paste out sum | awk '{$1 += $3; $2 += $4; NF = 2; print}' | tee sum   several times (15-20 times might be needed). Each time it runs, this command should add to the values in sum the corresponding values in out and write the results back to sum. What I get is that it works an unpredictable number of times, then sum reverts back to  2 20 5 50   I have later learned that  and solved the issue using a temporary file, still, this behaviour baffles me:   why does … | tee sum work at all (even if only for a limited number of iterations), while … &gt; sum never overwrites sum? why doesn't it work a predictable number of times? What is the use of the yield keyword in Python? What does it do? For example, I'm trying to understand this code1: def _get_child_candidates(self, distance, min_dist, max_dist):     if self._leftchild and distance - max_dist &lt; self._median:         yield self._leftchild     if self._rightchild and distance + max_dist &gt;= self._median:         yield self._rightchild    And this is the caller: result, candidates = [], [self] while candidates:     node = candidates.pop()     distance = node._get_dist(obj)     if distance &lt;= max_dist and distance &gt;= min_dist:         result.extend(node._values)     candidates.extend(node._get_child_candidates(distance, min_dist, max_dist)) return result  What happens when the method _get_child_candidates is called? Is a list returned? A single element? Is it called again? When will subsequent calls stop?   1. This piece of code was written by Jochen Schulz (jrschulz), who made a great Python library for metric spaces. This is the link to the complete source: [Module mspace][1]. Create Generic method constraining T to an Enum I'm building a function to extend the Enum.Parse concept that  Allows a default value to be parsed in case that an Enum value is not found Is case insensitive  So I wrote the following: public static T GetEnumFromString&lt;T&gt;(string value, T defaultValue) where T : Enum {     if (string.IsNullOrEmpty(value)) return defaultValue;     foreach (T item in Enum.GetValues(typeof(T)))     {         if (item.ToString().ToLower().Equals(value.Trim().ToLower())) return item;     }     return defaultValue; }  I am getting a Error Constraint cannot be special class System.Enum. Fair enough, but is there a workaround to allow a Generic Enum, or am I going to have to mimic the Parse function and pass a type as an attribute, which forces the ugly boxing requirement to your code. EDIT All suggestions below have been greatly appreciated, thanks. Have settled on (I've left the loop to maintain case insensitivity - I am using this when parsing XML) public static class EnumUtils {     public static T ParseEnum&lt;T&gt;(string value, T defaultValue) where T : struct, IConvertible     {         if (!typeof(T).IsEnum) throw new ArgumentException(&quot;T must be an enumerated type&quot;);         if (string.IsNullOrEmpty(value)) return defaultValue;          foreach (T item in Enum.GetValues(typeof(T)))         {             if (item.ToString().ToLower().Equals(value.Trim().ToLower())) return item;         }         return defaultValue;     } }  EDIT: (16th Feb 2015) Christopher Currens has posted  below, which is well worth a look, and an upvote. I will remove this edit if the solution bubbles further up the page. EDIT 2: (13th Apr 2021) As this has now been addressed, and supported, since C# 7.3, I have changed the accepted answer, though full perusal of the top answers is worth it for academic, and historical, interest :) Focal length of an ellipse and related results What will happen to my reputation when the Community Wiki status of a post is reversed?