Solved

display previous one day's date using SUN Solaris 7

Posted on 2002-03-06
7
1,865 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Red Hat Enterprise Linux 6.5 gets missing "/lib/ld-linux.so.2" 7 115
good comptia a+ teacher? 4 116
mobaxterm not able to change directory 28 291
OS Selection Menu 1 69
Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
#Citrix #POC #XenDesktop #vCenter #VMware #ESX
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

726 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