How To Add a Column of Numbers Using AWK
erics, January 1st, 2015
awk ‘{sum+=$1}END{print sum}’ inputFile
awk ‘{sum+=$1}END{print sum}’ inputFile
1 2 3 4 5 6 7 8 9 10 |
var sum = 0; // loop through each field jQuery(".sum").each(function() { //add only if the value is number if( ! isNaN(this.value) && this.value.length != 0 ) { sum += parseFloat(this.value); } }); //.toFixed() rounds the sum to 2 decimal places jQuery("#sum").html(sum.toFixed(2)); |
1 2 3 4 5 |
date_default_timezone_set('America/New_York'); $datetime1 = new DateTime('2009-10-31'); $datetime2 = new DateTime('now'); $interval = $datetime1->diff($datetime2); print $interval->format('%a days_elapsed'); |
http://www.php.net/manual/en/datetime.diff.php
$floor = int( $number / $increment ) * $increment;