Subtract minutes from date


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Subtract minutes from date
# 1  
Old 07-10-2014
Subtract minutes from date

Hi,

I am reading a particular date from a file using below command

Code:
WFLWDATE=$(sed '2q;d' FileA.prm)

The echo command outputs the correct date in variable WFLWDATE

Now I want to subtract 5 minutes from this variable. I am on AIX and unable to get anything working as expected.

Can you please suggest?

- Vrushank Patel

---------- Post updated at 08:47 AM ---------- Previous update was at 08:38 AM ----------

On this forum I was provided the below code to get 5 minutes subtracted. But this subtracted is from system date. I want to subtract from a variable

Code:
$(perl -e 'use POSIX qw(strftime);print scalar(strftime "%Y-%m-%d-%H.%M.%S" , localtime(time - 300)), "\n";' )

-Thanks
Vrushank Patel
# 2  
Old 07-10-2014
Check this thread in FAQ section: Date Arithmetic
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies

2. Shell Programming and Scripting

Subtract a file's modification date with current date

SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise Hi, In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file. How do I achieve this? Regards, Joe (2 Replies)
Discussion started by: roshanbi
2 Replies

3. Shell Programming and Scripting

Subtract date in a loop

I have a file with name and date--- $ cat file.log userA 01-06-2014 userB 25-05-2014 userC 16-05-2014 userC 01-03-2014 I want to search for the current date and get the name for that date. If current date is not found, go back 1 day and search and so on till it finds the... (2 Replies)
Discussion started by: Nagesh_1985
2 Replies

4. Shell Programming and Scripting

Add or Subtract the hours,minutes or seconds in the the time variable

Hello All, I am working on script where I need to add hours,minutes or seconds in the time.Time is not the current but it could be future time.I thought I can store that time in variable and add hours.minutes or second but I am not able to add that in the time that is stores in a variable. Time... (9 Replies)
Discussion started by: anuragpgtgerman
9 Replies

5. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

6. Shell Programming and Scripting

How to subtract time by 10 minutes in datecalc tool

Hi guys. I am trying to subtract 10 minutes from the current Unix system date and time. I have the datecalc provided here but it is mainly the date and not the time. Please check on how can i subtract 10 minutes from the current time using datecalc or any other shell scripting that will... (2 Replies)
Discussion started by: bantiloe
2 Replies

7. Shell Programming and Scripting

Perl - Extract 12 hour time, convert to 24 and subtract 15 minutes?

OK, I am by no means a programmer... I have been given the task to do some automation scripts. I have got most of it working from snippets I have found on the Web. One requirement has me stumped. The initial timing file created by the user is a comma delimited in the following format.... (4 Replies)
Discussion started by: autotuner
4 Replies

8. Shell Programming and Scripting

subtract minutes from time

i have the time 20100421043335 in format (date +%Y%m%d%H%M%S),and i want to be able to get the previous time 2 minutes ago,which is 20100421043135 (9 Replies)
Discussion started by: tomjones
9 Replies

9. Shell Programming and Scripting

Subtract two date in unix

I Have a long file like this 123122312 05/06/12 123123456 05/06/14 I want to take the difference of dates in two lines & print difference sidewise for the whole long files. Pl help me out. (1 Reply)
Discussion started by: vanand
1 Replies
Login or Register to Ask a Question