How to get yesterday date

Home Questions How to get yesterday date

This topic contains 1 reply, has 2 voices, and was last updated by   2 years, 3 months ago.

  • Author
    Posts
  • #6658 Reply

    admin
    Keymaster
    Online
    Topics: 65
    Replies: 65

    Hi All,
    In my shell script, i need yesterdays date to be assigned to a varaible. Using below command command I able to get the todays date. Please help me to get yesterdays date in same formay.(DD-MMM-YYYY)

    today_date=date '+%d-%h-%Y' | tr [:lower:] [:upper:]
    echo $today_date

  • #6739 Reply

    admin
    Keymaster
    Online
    Topics: 65
    Replies: 65

    This perfectly works for me in SunOS.

    yesterday_date=TZ=EST+24 date +%d-%h-%Y | tr [:lower:] [:upper:]
    echo ${yesterday_date}
    11-Nov-2015

Reply To: How to get yesterday date

You can use BBCodes to format your content.
Your account can't use Advanced BBCodes, they will be stripped before saving.

Your information: