Highlighted
Absent Member.
Absent Member.
48 views

getting Date - n value

I am trying to find a way to get date n days back. As long as n is less than current date(date portion) it is fine, I am able to get the value.

if date is in first n days of month the date - n goes to previous month and want to get %C%y%m%d value for that date (current date -n)

Any help is much appreciated
0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

Re: getting Date - n value

Pls elaborate the question.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: getting Date - n value

_d=`date +'%C%y%m%d'`
_d9=`expr $_d - 9`
echo _d : $_d _d9 : $_d9

output is as follows
_d : 20110127 _d9 : 20110118

I am using these to create new directories
with _d and delete old directories with _d9
(older than 9 days)

However this will not work when switching to new month

I want some help in this.

I am currently using date +'%j' so i get "day number" from 001 .. 366 However I wan to use Month and day format

Hope that explains
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: getting Date - n value

Not interested any more. Continuing wit %j attribute
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.