Sponsored Content
Top Forums Shell Programming and Scripting Getting a Date value based on day Post 303015844 by dnat on Friday 13th of April 2018 05:28:24 PM
Old 04-13-2018
Hi,

I am using Korn shell AIX ver 7.1

I tried this , but its giving me an error : date: illegal option -- d

Code:
date -d "$d -$(date -d $d +2) days" +"%m-%d-%Y"

If FILE_NAME_20180410 then I would need 20180410.

Thanks!
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, output, and code segments.

Last edited by Don Cragun; 04-13-2018 at 10:21 PM.. Reason: Add missing CODE & ICODE tags, again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting day from a date...

Hi, I have a date input in MMDDYYYY format.. I have to give the day (whether that DD is sunday/monday...) Is there any command for it... Or do I have to write a script for that... Thanks in Advance Yeheya (1 Reply)
Discussion started by: yeheyaansari
1 Replies

2. UNIX for Dummies Questions & Answers

Add a day to a given date

Hi, I have a date field which is a variable field being passed to the script from outside. I need to know how i can add 1 day to it. I have seen example of date subtraction but while adding each time date reaches 31 or 30 i have to put if else condition. Or for leap year also. Kindly let... (4 Replies)
Discussion started by: pallet
4 Replies

3. UNIX for Dummies Questions & Answers

date - 1 day

Hi, I have been trying just about every unix command to come up with yesterday's date (today's date - 1). I have seen all of the help on this forum, and none of it seems to work for me here. We are using Sun Solaris 9 Unix. I am using this script to create a .txt file with ftp commands that I will... (2 Replies)
Discussion started by: sfedak
2 Replies

4. Shell Programming and Scripting

value of variable based on time of the day

i would need some help in setting the value of a variable (TIME_NOW) depending on the time of the day ...e.g. if today's date is 12th April 2009 and if the current time is between midnight and 16:59:59 hrs then the TIME_NOW should be yesterday's date i.e. TIME_NOW=11 else if the current time... (3 Replies)
Discussion started by: zainravi
3 Replies

5. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

6. UNIX for Dummies Questions & Answers

Getting date -1 day not using GNU date

It's easy as pie to get the date minus one day on opensolaris: date -d "-1 day" +"%Y%m%d"run this command on our crappy Solaris 10 machines however (which I'm guessing doesn't have GNU date running on it) and you get: date: illegal option -- d date: illegal option -- 1 date: illegal option --... (5 Replies)
Discussion started by: rich@ardz
5 Replies

7. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

8. AIX

Need to get the next day's date of the user entered date

I need to get the next day's date of the user entered date for example: Enter date (yyyy/mm/yy): 2013/10/08I need to get the next day's date of the user entered date Desired Output: 2013/10/09Though there are ways to achieve this is Linux or Unix environment (date command) ,I need to... (1 Reply)
Discussion started by: rpm120
1 Replies

9. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

10. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies
Date::Format(3) 					User Contributed Perl Documentation					   Date::Format(3)

NAME
Date::Format - Date formating subroutines SYNOPSIS
use Date::Format; @lt = localtime(time); print time2str($template, time); print strftime($template, @lt); print time2str($template, time, $zone); print strftime($template, @lt, $zone); print ctime(time); print asctime(@lt); print ctime(time, $zone); print asctime(@lt, $zone); DESCRIPTION
This module provides routines to format dates into ASCII strings. They correspond to the C library routines "strftime" and "ctime". time2str(TEMPLATE, TIME [, ZONE]) "time2str" converts "TIME" into an ASCII string using the conversion specification given in "TEMPLATE". "ZONE" if given specifies the zone which the output is required to be in, "ZONE" defaults to your current zone. strftime(TEMPLATE, TIME [, ZONE]) "strftime" is similar to "time2str" with the exception that the time is passed as an array, such as the array returned by "localtime". ctime(TIME [, ZONE]) "ctime" calls "time2str" with the given arguments using the conversion specification "%a %b %e %T %Y " asctime(TIME [, ZONE]) "asctime" calls "time2str" with the given arguments using the conversion specification "%a %b %e %T %Y " MULTI-LANGUAGE SUPPORT Date::Format is capable of formating into several languages, these are English, French, German and Italian. Changing the language is done via a static method call, for example Date::Format->language('German'); will change the language in which all subsequent dates are formatted. This is only a first pass, I am considering changing this to be $lang = Date::Language->new('German'); $lang->time2str("%a %b %e %T %Y ", time); I am open to suggestions on this. CONVERSION SPECIFICATION
Each conversion specification is replaced by appropriate characters as described in the following list. The appropriate characters are determined by the LC_TIME category of the program's locale. %% PERCENT %a day of the week abbr %A day of the week %b month abbr %B month %c MM/DD/YY HH:MM:SS %C ctime format: Sat Nov 19 21:05:57 1994 %d numeric day of the month, with leading zeros (eg 01..31) %e numeric day of the month, without leading zeros (eg 1..31) %D MM/DD/YY %h month abbr %H hour, 24 hour clock, leading 0's) %I hour, 12 hour clock, leading 0's) %j day of the year %k hour %l hour, 12 hour clock %L month number, starting with 1 %m month number, starting with 01 %M minute, leading 0's %n NEWLINE %o ornate day of month -- "1st", "2nd", "25th", etc. %p AM or PM %P am or pm (Yes %p and %P are backwards :) %q Quarter number, starting with 1 %r time format: 09:05:57 PM %R time format: 21:05 %s seconds since the Epoch, UCT %S seconds, leading 0's %t TAB %T time format: 21:05:57 %U week number, Sunday as first day of week %w day of the week, numerically, Sunday == 0 %W week number, Monday as first day of week %x date format: 11/19/94 %X time format: 21:05:57 %y year (2 digits) %Y year (4 digits) %Z timezone in ascii. eg: PST %z timezone in format -/+0000 %d, %e, %H, %I, %j, %k, %l, %m, %M, %q, %y and %Y can be output in Roman numerals by prefixing the letter with "O", e.g. %OY will output the year as roman numerals. AUTHOR
Graham Barr <gbarr@pobox.com> COPYRIGHT
Copyright (c) 1995-1999 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.8.0 2002-03-07 Date::Format(3)
All times are GMT -4. The time now is 04:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy