UNIX date command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX date command
# 1  
Old 02-14-2006
UNIX date command

Hello...I have have the value of date command stored in a particular format in a variable...Is there any way by which I can increment the value of the date using unix only?Until now i was calling an sql query to increment the date..

Thanks
# 2  
Old 02-14-2006
Quote:
Originally Posted by tej.buch
particular format in a variable...Is there any way by which I can increment the value of the date using unix only?
What is the format ?

In general it is possible to increment the date.
# 3  
Old 02-14-2006
date command

hi the format is YYYYMMDD.......

eg : today is
20060214
# 4  
Old 02-14-2006
DATE query

well let me refine my query...

I have a set of dates in the format:
YYYYMMDD stored in a file...
what i do is read each value and increment the date in each..

till now i was calling an sql query to perform this task...

i searched the man pages and got the command
date --date="+1 day"
but the above command increments the date wrt to today's date..


my date may have any value...
so is there any command that can perform this operation..?
i dont want to invoke a shell script and would rather prefer a command ( if it exists)...........


thanks in advance......
# 5  
Old 02-15-2006
no easy way.

i'd use perl.

try the perl cookbook

perl CD
# 6  
Old 02-15-2006
See the Date Arithmetic article in our FAQ section especially datecalc...

$ datecalc -a 2006 02 14 + 1
2006 2 15
$
# 7  
Old 02-17-2006
date query

Yes..I had in fact lokked into the date calc script which is immensely useful for such calculations...but the problem is that that would entail an extra shell script in the package that is to be handed over to our clients and that i have been told to avoid ...If anyone comes across any single line command that would do the trick, kindly let me know............
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

2. 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

3. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

4. Shell Programming and Scripting

Using sed command replace date variable in unix

I need to use a shell script, using sed command how to replace date variable value in following format. 04/18/2012 11:38:55 Because the sed is treating the '/' as a parameter instead of the value of a variable, and hence there is the message as sed: command garbled: s/insert/04/18/2012... (9 Replies)
Discussion started by: jannusuresh
9 Replies

5. Shell Programming and Scripting

hp-unix stat command to get last change date of file

I'm on hp-unix. I would like a variable to hold the last change date of a file. I looked at the man pages for stat, but I don't see any examples and can't get the syntax right. Can anyone help me? Thank you. (2 Replies)
Discussion started by: sboxtops
2 Replies

6. Programming

I need code command(unix) date in c

hello please I need code command date in c I have a projet in my unv I am waiting your enswer:b::b: sorry on my english (1 Reply)
Discussion started by: mahfode
1 Replies

7. Shell Programming and Scripting

Compare date from db2 table to yesterday's Unix system date

I am currently running the following Korn shell script which works fine: #!/usr/bin/ksh count=`db2 -x "select count(*) from schema.tablename"` echo "count" I would like to add a "where" clause to the 2nd line that would allow me to get a record count of all the records from schema.tablename... (9 Replies)
Discussion started by: sasaliasim
9 Replies

8. UNIX for Dummies Questions & Answers

Command DATE in UNIX System

I have a problem... it's possible execute a command DATE with the sintax of LINUX system ??? Example: in Linux i can execute the command line : date -- set "10 minutes" and i have a output the date with the actual date - 10 min. It's possible have the same rusult in the Unix system ????? ... (3 Replies)
Discussion started by: ZINGARO
3 Replies

9. UNIX for Dummies Questions & Answers

Unix Date Command

IS there a way to use the unix date command to find the 2nd Saturday fo every month? Each Month I want to execute a specific command only of the 2nd Saturday. (1 Reply)
Discussion started by: redsoxfan
1 Replies

10. UNIX for Dummies Questions & Answers

unix date command

Hi there I am using the following command to get today's date: Date=`date '+%Y%m%d'` This has the format 20040409 What I want is today's date -1 i.e. get yesterdays date. What is the command for this? Thanks :) (1 Reply)
Discussion started by: niamh
1 Replies
Login or Register to Ask a Question