GNU bug report logs - #6485
Days Between Dates? How?

Previous Next

Package: coreutils;

Reported by: upload amritsar <upload.amritsar <at> licindia.com>

Date: Mon, 21 Jun 2010 16:26:01 UTC

Severity: normal

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6485 in the body.
You can then email your comments to 6485 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#6485; Package coreutils. (Mon, 21 Jun 2010 16:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to upload amritsar <upload.amritsar <at> licindia.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 21 Jun 2010 16:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: upload amritsar <upload.amritsar <at> licindia.com>
To: <bug-coreutils <at> gnu.org>
Cc: <dipakhp <at> rediffmail.com>
Subject: i have one question?
Date: Mon, 21 Jun 2010 13:49:09 +0530
Hi,
Good Morning

can you plese tell me what is the procedure or command to find the days
between two date
supoose we have 2 date first one 01-01-2008 second one 21-06-2010 then 
how can we calculate days between these two date .

Regards,
Deepak
+91-9988049558


"The information contained in this electronic message and any attachments to this 
message are intended for exclusive use of the addressee(s) and may contain 
confidential or privileged information. If you are not the intended recipient, please 
notify the sender at LIC OF INDIA or co_mailadmin <at> licindia.com immediately and 
destroy all copies of this message and any attachments. The views expressed in 
this E-mail message / Attachments, are those of the individual sender."
----------



Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#6485; Package coreutils. (Mon, 21 Jun 2010 21:48:02 GMT) Full text and rfc822 format available.

Message #8 received at 6485 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: upload amritsar <upload.amritsar <at> licindia.com>
Cc: dipakhp <at> rediffmail.com, 6485 <at> debbugs.gnu.org
Subject: Re: bug#6485: i have one question?
Date: Mon, 21 Jun 2010 15:47:16 -0600
retitle 6485 Days Between Dates?  How?
thanks

upload amritsar wrote:
> can you plese tell me what is the procedure or command to find the days
> between two date

If you would be so kind could you in the future address these types of
questions to coreutils <at> gnu.org instead of bug-coreutils?  The
bug-coreutils address has been changed from "all-discussion" to
"bug-discussion" and along with that change every message here now
opens a bug ticket in the bug tracking system so that we don't lose
track of reported bugs.  The coreutils <at> gnu.org address was created for
general discussion that isn't attached to the bug tracking system.
Thanks!

> supoose we have 2 date first one 01-01-2008 second one 21-06-2010 then 
> how can we calculate days between these two date .

GNU date itself doesn't include any direct support for finding days
between dates.  But it can be used as part of a script to find this
information.  The technique is to convert each date to an integer
value such as a Julian Day Number or seconds of the Unix epoch and
then do take the difference and convert back.  I will use Unix seconds
in an example.  Plus the date must be in a format that can be parsed
by GNU date.

  date1="2008-01-01"
  date2="2010-06-21"
  date1seconds=$(date -d "$date1 12:00" +%s)
  date2seconds=$(date -d "$date2 12:00" +%s)
  totalseconds=$(( $date2seconds - $date1seconds))
  secondsperday=86400
  days=$(( $totalseconds / $secondsperday ))
  echo "There were $days days between $date1 and $date2"

And of course that can be shorted up considerably by applying the
constructs inline but I wanted to make things as illustrative as
possible and so expanded them out.

  $ echo Days between dates: $(( ( $(date -d "2010-06-21 12:00" +%s) - $(date -d "2008-01-01 12:00" +%s) ) / 86400 ))

I find it is often best to do date calculations using 12:00 noon so as
to avoid any daylight savings time issues.

> "The information contained in this electronic message and any
> attachments to this message are intended for exclusive use of the
> addressee(s) and may contain confidential or privileged
> information. If you are not the intended recipient, please notify
> the sender at LIC OF INDIA or co_mailadmin <at> licindia.com immediately
> and destroy all copies of this message and any attachments. The
> views expressed in this E-mail message / Attachments, are those of
> the individual sender."

Please don't post questions to public mailing lists with such a
disclaimer attached to it.  They are worthless and completely
unenforceable but annoy many of us greatly.  Please see this
reference.

  http://goldmark.org/jeff/stupid-disclaimers/

If you cannot avoid such a disclaimer being attached to your email
because your company does it to you automatically then please do not
send mail from your company email account.  Instead please sign up for
and use one of the many free email accounts that are readily available
on the Internet when corresponding with the Internet community.  They
are free.  They are available.  Do it for the good of the community.

Bob




bug closed, send any further explanations to upload amritsar <upload.amritsar <at> licindia.com> Request was from Bob Proulx <bob <at> proulx.com> to control <at> debbugs.gnu.org. (Mon, 21 Jun 2010 21:51:01 GMT) Full text and rfc822 format available.

Changed bug title to 'Days Between Dates? How?' from 'i have one question?' Request was from Bob Proulx <bob <at> proulx.com> to control <at> debbugs.gnu.org. (Mon, 21 Jun 2010 22:11:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Jul 2010 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 30 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.