I am trying to execute date command in unix server for yesterday. The commands tried are :

date --date ="1 day ago"
date --date ="1 days ago"  
date --date ="yesterday
date --date ="-1 day"

These command work in a server but the same command does not work in few other servers, where date prints properly the current date. Could anyone suggest what could be the issue with the other servers?

The server details: SunOS wupsa02a0014 5.10 Generic_147440-15 sun4u sparc SUNW,SPARC-Enterprise

  • Stephane has already provided the answer, but I wanted to point out that you should look to the man pages for issues like this. Then you'd know you were trying to use options that are not available in a (POSIX) standard date command. Solaris' man pages are detailed and complete.
    – Tim B
    Mar 27, 2013 at 12:30

1 Answer 1


Either remove the = or the space after --date and change those Unicode quotes (U201D) to the ASCII quote character (U0022). So:

date --date="1 day ago"


date --date yesterday


date -d yesterday

Note that -d/--date is not a standard Unix date option and is only available with GNU date. So if that Unix server is not a Linux distribution or other GNU based system, you'll have to install GNU date there or use alternative options for date calculation.

  • I get an error in all the above cases like: date: illegal option -- d, date: illegal option -- date=1 day ago etc
    – Swagatika
    Mar 27, 2013 at 7:03
  • 3
    @Swagatika. Yes, your date is not the GNU date. Mar 27, 2013 at 7:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .