Solved

display previous one day's date using SUN Solaris 7

Posted on 2002-03-06
7
1,852 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

829 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