Sponsored Content
Top Forums Shell Programming and Scripting Calculating the difference between dates Post 302363868 by claw82 on Wednesday 21st of October 2009 01:02:05 PM
Old 10-21-2009
Thanks Scrutinizer, is just that i need!!!

And thanks to the other people too!

Last edited by claw82; 10-21-2009 at 03:07 PM..

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Difference between two dates...

Hi All, Wish you a Happy New year... I have to find the difference between two dates, the result should be the number of days. I have seen the "datecalc" function. Its good, can I have any other alternative. Thanks in Advance Raju (4 Replies)
Discussion started by: rajus19
4 Replies

2. Shell Programming and Scripting

calculating the time difference, when the script was executed and the currenent file

Hi, I has created the shell script in HP_UX 11.23 and using the command, echo $(date +%Y%m%d%H%M%S) > $DIR/alert, placing the time of running the script into a file alert. I want to compare the time in the above file alert with the current time.If difference is more than 5 min, then print the... (7 Replies)
Discussion started by: velocitnitin
7 Replies

3. Shell Programming and Scripting

parsing and calculating difference.

Hi, I have a file with the contents as following Access Time: Thu Nov 6 16:43:45 2008 Modify Time: Thu Nov 6 16:43:45 2008 Change Time: Thu Nov 6 16:43:45 2008 Access Time: Thu Nov 6 16:43:02 2008 Modify Time: Thu Nov 6 16:44:01 2008 Change Time: Thu Nov 6 16:44:01 2008 I need... (3 Replies)
Discussion started by: meetmano143
3 Replies

4. UNIX and Linux Applications

sqlite: calculating with dates - compare current date minus 6 months with stored record

Hi I have a table with name, date in format DD.MM.YYYY. I need to something like this (I try to explain in pseudo code) if SYSDATE (current date) minus 6 months > $expiry date print OK else print NOK with $name and $expiry date I know this is possible with Oracle. How to do this... (0 Replies)
Discussion started by: slashdotweenie
0 Replies

5. Shell Programming and Scripting

Awk program for calculating dates.

Hi All, I have a txt file which has hundreds of lines and 41 fields. I have a requirement to pick up field 14 from the text file which is a date fiels in the following format. Field 14 : Data Type : NUMERIC DATE (YYYYMMDD) Field Length : 8 Example of Data :20090415 Field 42 : Data Type... (2 Replies)
Discussion started by: nua7
2 Replies

6. UNIX for Advanced & Expert Users

Help with Calculating time difference between many directories in UNIX

A report needs to come some what similar to this No of elements Stream Batch No Load time A B C D A,B,C im able to get quite easily wc -l /usr/local/intranet/areas/prod/output/SRGW_0?/*/MESSAGE_T.dat O/P of above command. A B C ... (1 Reply)
Discussion started by: peckenson
1 Replies

7. Shell Programming and Scripting

Difference between two dates

hi all, I need a help for below requirement. Difference between two dates"12-11-2009" and "03-25-2012" (mm-dd-yy format") in weeks and days and hours Please help me for this. Thanks in adv.... I am working in AIX, so dont have below command:- date --version (2 Replies)
Discussion started by: gani_85
2 Replies

8. Shell Programming and Scripting

Trouble calculating difference in number of days

Hi all, I have a requirement to calculate the difference of number of days of time stamp of a file and system date and if the difference is greater than 15 days it should prompt as previous month file otherwise current month file. Below is the code i used and it is working fine till now. (You... (2 Replies)
Discussion started by: Ravindra Swan
2 Replies

9. UNIX for Beginners Questions & Answers

Difference between two dates

Hi There I am trying to find the difference between two dates in seconds, by taking the first 10 digits of the file name itself, which I have done as shown below: current_time=`date +%s` last_login_of_tim=`date -d @1489662376 +%s` diff_sec=$(($current_time-$last_login_of_tim)) ... (5 Replies)
Discussion started by: simpsa27
5 Replies

10. Shell Programming and Scripting

Calculating Time difference Between two Rows in Linux

16:45:51 10051 77845 16:45:51 10051 77845 16:46:52 10051 77846 16:46:53 10051 77846 Match the last PID then subtract second line time with first line. Please help me with any command or script. working in media company on a project OS: RHEl7 tried command: awk 'function... (2 Replies)
Discussion started by: vivekn
2 Replies

MongoDB::command - Execute a database command

public array MongoDB::command (array $command, [array $options = array()], [string &$hash]) DESCRIPTION
Almost everything that is not a CRUD operation can be done with a database command. Need to know the database version? There's a command for that. Need to do aggregation? There's a command for that. Need to turn up logging? You get the idea. This method is identical to: <?php public function command($data) { return $this->selectCollection('$cmd')->findOne($data); } ?> PARAMETERS
o $command - The query to send. o $options - An array of options for the index creation. Currently available options include: o "socketTimeoutMS"This option specifies the time limit, in milliseconds, for socket communication. If the server does not respond within the timeout period, a MongoCursorTimeoutException will be thrown and there will be no way to determine if the server actually handled the write or not. A value of -1 may be specified to block indefinitely. The default value for MongoClient is 30000 (30 seconds). The following options are deprecated and should no longer be used: o "timeout"Deprecated alias for "socketTimeoutMS". o $hash - Set to the connection hash of the server that executed the command. When the command result is suitable for creating a MongoCom- mandCursor, the hash is intended to be passed to MongoCommandCursor.createFromDocument(3). The hash will also correspond to a connection returned from MongoClient.getConnections(3). CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 1.5.0 | | | | | | | Renamed the "timeout" option to "socketTime- | | | outMS". Emits E_DEPRECATED when "timeout" is | | | used. Added hash by-reference parameter. | | | | | 1.2.0 | | | | | | | Added options parameter with a single option: | | | "timeout". | | | | +--------+---------------------------------------------------+ RETURN VALUES
Returns database response. Every database response is always maximum one document, which means that the result of a database command can never exceed 16MB. The resulting document's structure depends on the command, but most results will have the ok field to indicate success or failure and results containing an array of each of the resulting documents. EXAMPLES
Example #1 MongoDB.command(3) "distinct" example Finding all of the distinct values for a key. <?php $people = $db->people; $people->insert(array("name" => "Joe", "age" => 4)); $people->insert(array("name" => "Sally", "age" => 22)); $people->insert(array("name" => "Dave", "age" => 22)); $people->insert(array("name" => "Molly", "age" => 87)); $ages = $db->command(array("distinct" => "people", "key" => "age")); foreach ($ages['values'] as $age) { echo "$age "; } ?> The above example will output something similar to: 22 87 Example #2 MongoDB.command(3) "distinct" example Finding all of the distinct values for a key, where the value is larger than or equal to 18. <?php $people = $db->people; $people->insert(array("name" => "Joe", "age" => 4)); $people->insert(array("name" => "Sally", "age" => 22)); $people->insert(array("name" => "Dave", "age" => 22)); $people->insert(array("name" => "Molly", "age" => 87)); $ages = $db->command( array( "distinct" => "people", "key" => "age", "query" => array("age" => array('$gte' => 18)) ) ); foreach ($ages['values'] as $age) { echo "$age "; } ?> The above example will output something similar to: 87 Example #3 MongoDB.command(3) MapReduce example Get all users with at least on "sale" event, and how many times each of these users has had a sale. <?php // sample event document $events->insert(array("user_id" => $id, "type" => $type, "time" => new MongoDate(), "desc" => $description)); // construct map and reduce functions $map = new MongoCode("function() { emit(this.user_id,1); }"); $reduce = new MongoCode("function(k, vals) { ". "var sum = 0;". "for (var i in vals) {". "sum += vals[i];". "}". "return sum; }"); $sales = $db->command(array( "mapreduce" => "events", "map" => $map, "reduce" => $reduce, "query" => array("type" => "sale"), "out" => array("merge" => "eventCounts"))); $users = $db->selectCollection($sales['result'])->find(); foreach ($users as $user) { echo "{$user['_id']} had {$user['value']} sale(s). "; } ?> The above example will output something similar to: User 49902cde5162504500b45c2c had 14 sale(s). User 4af467e4fd543cce7b0ea8e2 had 1 sale(s). Note Using MongoCode This example uses MongoCode, which can also take a scope argument. However, at the moment, MongoDB does not support using scopes in MapReduce. If you would like to use client-side variables in the MapReduce functions, you can add them to the global scope by using the optional scope field with the database command. See the MapReduce documentation for more informa- tion. Note The out argument Before 1.8.0, the out argument was optional. If you did not use it, MapReduce results would be written to a temporary col- lection, which would be deleted when your connection was closed. In 1.8.0+, the out argument is required. See the MapReduce documentation for more information. Example #4 MongoDB.command(3) "geoNear" example This example shows how to use the geoNear command. <?php $m = new MongoClient(); $d = $m->demo; $c = $d->poiConcat; $r = $d->command(array( 'geoNear' => "poiConcat", // Search in the poiConcat collection 'near' => array(-0.08, 51.48), // Search near 51.48oN, 0.08oE 'spherical' => true, // Enable spherical search 'num' => 5, // Maximum 5 returned documents )); print_r($r); ?> SEE ALSO
MongoCollection::aggregate, MongoCollection::findAndModify, MongoCollection::group. MongoDB core docs on database commands and on individual commands: findAndModify, getLastError, and repairDatabase (dozens more exist, there are merely a few examples). PHP Documentation Group MONGODB.COMMAND(3)

Featured Tech Videos

All times are GMT -4. The time now is 12:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy