Solved

display previous one day's date using SUN Solaris 7

Posted on 2002-03-06
7
1,877 Views
Last Modified: 2013-12-05
Hi!
I have some UNIX script need to help from you all experts.
How do display previous one day's using UNIX script on SUN Solaris?
The date of type display is YYMMDD

E.g: (1) "For display today date"
#date
Thu Mar  7 13:36:12 SGT 2002
 
E.g: (2) "For display today date with type YYMMDD"
#date -u '+%y%m%d'
020307

How to display the date on one day before current day?
I meant if today is 020307 (2002 March 07), when I type the command it should be display: 020306 (2002 March 6).

Thank you very much!
Geoffry.
0
Comment
Question by:geoffry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 24

Expert Comment

by:SunBow
ID: 6847740
Change the clock.
If your application needs that so badly from OS, for example, to simulate being in another country, another time zone, etc., then best to just configure the server as if it was located in the area being serviced. That gets around a few other problems, such as TZ & DST.

If not, just a cosmetic for application, then the tools of the application should modify it, and not require any hacks to the OS clock.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6847743
(not to mention synchronization and networking communication)
0
 
LVL 4

Expert Comment

by:newmang
ID: 6848573
Can you explain the situation where you need this function as the way to do it would depend on why you want to do it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Accepted Solution

by:
ahoffmann earned 300 total points
ID: 6852675
env TZ=GMT+24 date +%y%m%d
# assuming that your TZ is GMT
0
 
LVL 1

Expert Comment

by:mbreuer
ID: 6861677
Don't know if the standard sun date routine has this... linux does:

date --date=yesterday works for me.  You could use the gpl'd date routine and compile on solaris if not already supported.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6862656
--date is a GNU option;
My TZ suggestion works on any flaviour of UNIX/Linux for at least 24 hours timeshift (up to .. I don't realy know, depends on UNIX ;-)
0
 
LVL 2

Author Comment

by:geoffry
ID: 6887526
Thank you very much!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question