Unix/Linux Go Back    

Answers to Frequently Asked Questions FAQ for UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Yesterdays Date/Date Arithmetic

Answers to Frequently Asked Questions

date, yestedays date

Closed Linux or Unix Question    
Thread Tools Search this Thread Display Modes
Old Unix and Linux 04-26-2004
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
Join Date: Aug 2001
Last Activity: 8 August 2015, 12:06 PM EDT
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 454 Times in 266 Posts
Debian Yesterdays Date/Date Arithmetic

We get a lot of threads asking how to find yesterday's date. Or how to find the date exactly 2 months into the future, etc.

I wrote a script called datecalc that can do virtually any kind of date arithmetic. datecalc is my favorite solution. But there are several other solutions to consider. Here are some other threads....

Date function question
This thread has a perl solution, an adb solution, and an early script written by me.

Getting yesterday DATE
The last post in this thread mentions altering the TZ variable. I don't think this is very portable nor general, but it is an interesting option.

Subtracting Two months from date
This thread mentions the advanced options available with the GNU date command.

date manipulation
This thread has another perl solution.

Date Logic
Whoa... This thread has one post that suggests using a database.

Date calculation script
Here is another shell script.

get yesterday in yyyymmdd format
Review of some of above techniques by folks who didn't read this FAQ. Linux

And a few more threads that you may find interesting....

How to find Previous date and Coming date
how to get number of seconds
Date Substraction
Calculte date time
Add Date
Julian Date
building text file with calendar dates
convert date in lilian format for shell (AIX)
Yesterday's date function
Calculating the day of the week
validating dates
Time & Date Manupulations
calcuate the week number of a given date
Keeping the format ...
Getting sysdate - 2 by an unix command
how to get month last date in unix
How to get the weekday of the given date?

And some interesting magazine articles:

Date arithmetic, Part 1
Date arithmetic, Part 2
Date arithmetic, Part 3

And a interesting web site:

Hermetic Systems: Calendars, Encryption, Astronomy, Prime Numbers and More

This thread shows how to do time arithmetic using the GNU date program.

Last edited by Neo; 10-25-2010 at 05:17 AM.. Reason: Removed Dead Link
The Following 5 Users Say Thank You to Perderabo For This Useful Post:
CarloM (01-15-2014), Corentor (01-30-2012), derekludwig (12-24-2014), dhruuv369 (04-09-2015), Yoda (10-18-2013)
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to get the yesterdays date? jam_prasanna Shell Programming and Scripting 2 07-19-2010 04:29 AM
Need to pull Yesterdays Date... cards0622 UNIX for Dummies Questions & Answers 2 03-04-2009 12:53 PM
How to get yesterdays julian date er_ashu UNIX for Dummies Questions & Answers 3 01-24-2009 01:20 PM
yesterdays date sujju1985 Shell Programming and Scripting 2 12-29-2008 06:49 PM
Get yesterdays date given todays date magikminox UNIX for Dummies Questions & Answers 2 07-11-2008 07:56 AM

All times are GMT -4. The time now is 07:31 PM.