Finding the number of days between two dates

Finding the number of days between two dates

How to find number of days between two dates using PHP? 1:$now = time(); // or your date as well$your_date = strtotime(2010-01-01);$datediff = $now - $your_date;echo round($datediff / (60 * 60 * 24)); 2:If you're using PHP 5.3

EF: Include with where clause

EF: Include with where clause

As the title suggest I am looking for a way to do a where clause in combination with an include.Here is my situations:I am responsible for the support of a large application full of code smells.Changing too much code causes bugs everywhere

Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago…

Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago…

I am trying to convert a timestamp of the format 2009-09-12 20:57:19 and turn it into something like 3 minutes ago with PHP.I found a useful script to do this, but I think it's looking for a different format to be used as the time variable.

How can I remove duplicate rows?

How can I remove duplicate rows?

What is the best way to remove duplicate rows from a fairly large SQL Server table (i.e. 300,000+ rows)?The rows, of course, will not be perfect duplicates because of the existence of the RowID identity field.MyTableRowID int not null ident

Are PHP short tags acceptable to use?

Are PHP short tags acceptable to use?

Here's the information according to the official documentation: There are four different pairs of opening and closing tags which can be used in PHP. Two of those, <?php ?> and <script language="php"> </script>, are always available. Th

How to reverse the order in a FOR loop

How to reverse the order in a FOR loop

I've a simple FOR statement like this:var num = 10, reverse = false;for(i=0;i

Can I type assert a slice of interface values?

Can I type assert a slice of interface values?

I am trying to type assert from a []Node, to []Symbol. In my code, Symbol implements the Node interface.Here is some surrounding code: 43 func applyLambda(args []Node, env Env) Node { 44 if len(args) > 2 { 45 panic("invalid argu

using sql count in a case statement

using sql count in a case statement

I have a table and i need to present the output in the following fashion.tb_a:col1 | reg_id | rsp_ind Count of rows with rsp_ind = 0 as 'New' and 1 as 'Accepted'The output should be NEW | Accepted9 | 10I tried using the following query.

Django ORM, group by day

Django ORM, group by day

I am trying to group products by DAY, however date_created is a datetime field.Product.objects.values('date_created') \ .annotate(available=Count('available_quantity'))returns:[ {'date_created': datetime.datetime(2012, 4, 1

SQL - STDEVP or STDEV and how to use it?

SQL - STDEVP or STDEV and how to use it?

I have a table:LocationId OriginalValue Mean1 0.45 3.99 2 0.33 3.993 16.74 3.994 3.31 3.99and so forth...How would I work out the Standard Deviation using this table and al

Getting typed results from ActiveRecord raw SQL

Getting typed results from ActiveRecord raw SQL

In Sequel, I can do:irb(main):003:0> DB["select false"].get=> falseWhich returns a false boolean. I'd like to be able to do something similar in ActiveRecord:irb(main):007:0> ActiveRecord::Base.connection.select_value "select false"=> "f"A

Does an empty array in .NET use any space?

Does an empty array in .NET use any space?

I have some code where I'm returning an array of objects.Here's a simplified example:string[] GetTheStuff() { List s = null; if( somePredicate() ) { s = new List(); // imagine we load some data or something } return (s ==

Animating max-height with CSS transitions

Animating max-height with CSS transitions

I want to create an expand/collapse animation that's powered only by classnames (javascript is used to toggle the classnames).I'm giving one class max-height: 4em; overflow: hidden; and the other max-height: 255em; (I also tried the value n

What is the difference between destroy() and delete() methods in Laravel?

What is the difference between destroy() and delete() methods in Laravel?

I'm having a minor issue with Laravel 4. I'd like to use the delete() method on a record but for some reason it doesn't actually delete the record. destroy() does, though, so my code is good. Also, if I pass Teetime::where('date', '=', $for

MySQL Nested Select Query?

MySQL Nested Select Query?

Ok, so I have the following query:SELECT MIN(`date`), `player_name`FROM `player_playtime`GROUP BY `player_name`I then need to use this result inside the following query:SELECT DATE(`date`) , COUNT(DISTINCT `player_name`)FROM `player_playt

how to store grep command result in some variable in shell

how to store grep command result in some variable in shell

I want to find out number of directories and files in home directory and want to store count some variable in a shell script. I am using following set of commands.command="ls -l | grep -c \"rahul.*patle\""eval $commandi want to store this c

Using SLRequest in iOS 6 with Facebook

Using SLRequest in iOS 6 with Facebook

I'm currently trying to use an SLRequest to post a status on to facebook this is the code i have:ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifie

Protect PDF docs from being directly accessed in URL

Protect PDF docs from being directly accessed in URL

I want to protect a pdf file from being directly linked but instead have my logged in users be able to access it. I have a link which currently goes to a javascript function which posts a form: $('nameofdoc').setProperty('value',doc);

Is primefaces live scrolling compatible with Lazy loading

Is primefaces live scrolling compatible with Lazy loading

I have a datatable where huge data sets need to be displayed.So i decided to go with primefaces live scrolling.I also got to know that to improve datatable performance with huge data sets we need to implement lazy loading.With reference to

Finding all non-conflicting combinations of values from multiple lists of values

Finding all non-conflicting combinations of values from multiple lists of values

I have the following array which contains arrays of values:$array = array( array('1', '2'), array('a', 'b', 'c'), array('x', 'y'),);There can be any number of arrays and an array can contain any number of values. I currently have a

Using CurrentDomain.SetData(“APP_CONFIG_FILE”) doesn't work in PowerShell ISE

Using CurrentDomain.SetData(“APP_CONFIG_FILE”) doesn't work in PowerShell ISE

I'm attempting to use a .NET 4.0 assembly in PowerShell ISE, and trying to change the config file which is used via:[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $PathToConfig); [Configuration.ConfigurationManager]::Connec

how to draw two half circles in ggplot in r

how to draw two half circles in ggplot in r

How can I make a plot like this with two different-sized half circles (or other shapes such as triangles etc.)?I've looked into a few options: Another post suggested using some unicode symbol, that didn't work for me. And if I use a vector

Symfony2: Test on ArrayCollection gives “Unreachable field”

Symfony2: Test on ArrayCollection gives “Unreachable field”

In a functional test of a form to add members of an ArrayCollection there is this statement: $form['client[members][1][fname]'] = 'Benny';The field name was verified with a DOM inspector.The console output at this line is:InvalidArgumentEx

data.table or dplyr - data manipulation

data.table or dplyr - data manipulation

I have the following dataDate Col1 Col22014-01-01 123 122014-01-01 123 212014-01-01 124 322014-01-01 125 322014-01-02 123 342014-01-02 126 242014-01-02 12

PL/SQL bulk collect into associative array with sparse key

PL/SQL bulk collect into associative array with sparse key

I want to execute a SQL query inside PL/SQL and populate the results into an associative array, where one of the columns in the SQL becomes the key in the associative array. For example, say I have a table Person with columnsPERSON_ID INT