Setting Date Variable +1 date

Thread Tools Search this Thread
Operating Systems Solaris Setting Date Variable +1 date
# 1  
Old 07-25-2013
Setting Date Variable +1 date

I need to set a date varable within ksh that will set the date to the next day in the format 25-JUL-2013 - any help would be appreciated.
# 2  
Old 07-25-2013
Portable options for date math are limited. You might have the super-new ksh needed for that, or not. You might have the super-new nawk needed for that, or not. You might have GNU date available, or not.

Or you could use perl, which is available the same way almost everywhere. The current day, in dd-Mon-yyyy format, plus 86400 seconds:

DATE=$(perl -e 'use POSIX qw(strftime);  print strftime $ARGV[0]."\n", localtime(time()+$ARGV[1]);' -- "%d-%b-%Y" 86400 )

# 3  
Old 07-25-2013
If you don't have the GNU functionality, try tweaking your timezone $TZ

Some systems have a limitation that you cannot go forwards or backwards beyond 24 hours, but some allow a seemingly limitless offset. If your value for $TZ is like GMT0BST........ then you can easily set it:-
date +%b-%b-%Y

If you are with EST5EDT, then:-
date +%b-%b-%Y

Some systems do not have a TZ set. If so, you need to export the value and unset it at the end:-
export TZ=GMT-24BST
date +%b-%b-%Y
unset TZ

I hope that this gives you an option, but it is highly OS specific in what it will allow. There are various other date calculation threads on the forums here to search through too.

# 4  
Old 07-25-2013
Changing TZ worked - thanks so much for your help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies

2. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date 19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

3. Shell Programming and Scripting

Convert a date stored in a variable to epoch date

I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date #!/usr/bin/ksh set -x for s in server ; do ssh -T $s <<-EOF from_date="12-Jan-2015 12:02:09" to_date="24-Jan-2015 13:02:09" echo \$from_date echo... (7 Replies)
Discussion started by: raj48
7 Replies

4. Shell Programming and Scripting

LINUX ---> Add one date to a date variable

Hi All, I am trying to add one day to the busdt variable i am extracting from a file (DynamicParam.env). I am deriving the busdt as below. Is there any function which I can use to derive as below. If busdt=20120910, then the new derived variable value should be 20120911 If... (2 Replies)
Discussion started by: dsfreddie
2 Replies

5. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

6. Shell Programming and Scripting

Setting the date.

I am modifying some script and need to have the script reflect the current date. I have the script below. In the section yy="2010",mm="07", dd="12" What would I need to change to have the script automatically input the current year month & date instead of manually updated the script daily? ... (2 Replies)
Discussion started by: libertyforall
2 Replies

7. UNIX for Dummies Questions & Answers

setting the system date

Okay so I'm not really a newbie, but this bugs the crap out of me (rant on). Every so often I need to change the system time. I run "man date" and always find the "date -s" command, but for who knows how long, the manual page has *never* listed the format of the input string required to set the... (1 Reply)
Discussion started by: qneill
1 Replies

8. Shell Programming and Scripting

How to check date variable according to the current date?

Hi folks, I need to write a script that should activate a process according to the current hour. The process should be activatet only if the hour is between midnight (00:00) and 07:00. How should I create the condition? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

9. Programming

Setting Environment Variable date

Hi to all... I'm currently running a C++ program in Unix environment and it is dependent to a Unix environment variable with a date value. ex: echo $DateToday 20060403 I want to change that date in my C++ program, changing the value date to 20061120 and revert back to original... (6 Replies)
Discussion started by: d3ck_tm
6 Replies

10. UNIX for Dummies Questions & Answers

setting date and time

how do i set the system date and time? i know i have to be root to do it but i'm new to unix--really new--and some of this stuff seems really cryptic. thanks for any help.:confused: (2 Replies)
Discussion started by: singlefin
2 Replies
Login or Register to Ask a Question

Featured Tech Videos