Friendz.. plz help me on this date function.


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Friendz.. plz help me on this date function.
# 8  
Old 07-20-2008
AIX has ksh93, so the following should work
Code:
$ printf "%T\n" "01012008"
Tue Jan  1 20:08:00 EST 2008
$ printf "%T\n" "01012008 last saturday"
Sat Dec 29 20:08:00 EST 2007
$ printf "%T\n" "01012008 next sunday"
Sun Jan 13 20:08:00 EST 2008
$ printf "%T\n" "01012008 this sunday"
Sun Jan  6 20:08:00 EST 2008
$

# 9  
Old 07-21-2008
Hello All for all your feedback.

I tried "fpmurphy" suggestion in regards to ksh93 but it doesn't appear that this has been installed on our aix server. Smilie

I did find a useful code that's doing a similar calculation to find "last Sunday" from an input date but it's written in Perl. Can someone assist me in converting it to a shell script? We also do not have Perl available here.

https://www.unix.com/unix-dummies-que...sing-perl.html

Thank you.
# 10  
Old 07-22-2008
Quote:
Originally Posted by pchang
Hello All for all your feedback.

I tried "fpmurphy" suggestion in regards to ksh93 but it doesn't appear that this has been installed on our aix server. Smilie
.
Humm, what version of AIX are you using?
What is the output of "print $KSH_VERSION" and "print ${.sh.version}"
# 11  
Old 07-22-2008
AIX Version 5.2

$ print $KSH_VERSION

$ print ${.sh.version}
Version M-12/28/93e

I tried your example below and I get the following error:

printf "%T\n" "01012008"
ksh93: printf: T: unknown format specifier

Thank you.
# 12  
Old 07-22-2008
Quote:
$ print ${.sh.version}
Version M-12/28/93e
You indeed have ksh93 installed but it is a very old version. That particular version was release at the end of July 1996. I believe that you need version h or better (released in 1999) for "%T" functionality.
# 13  
Old 07-22-2008
Thanks fpmurphy for your quick reply....

Unfortunately, I'm not part of the Unix team system administrators and whichever versions they decide to install on the server is up to them.

So, is there any other options for me???
# 14  
Old 07-23-2008
I'm thinking of a potential solution - can you let me know if this will work or not?

Question: For any given date, get previous Saturday's date.

Solution: Current date => convert to julian date (A)
(for example: 205 for today's date)

Current date => get day of the week (B)
(for example: 3 for today's date)

Previous Saturday = (A)-(B)-1 (since sunday = 0) <= (205 - 3)-1 = 201

Then convert julian date format back to calendar date format.....is there an easy way to do this?

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Plz Help in sorting the data on date basis

I have file a.txt having below data cat a.txt 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 IN 1514 0000764631 01-NOV-13 2.38.11.00.100089 IN 1514 0000856571 01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531 01-JUN-13 2.38.19.00.100000 IN 2698 0000764493... (5 Replies)
Discussion started by: ranabhavish
5 Replies

2. UNIX for Dummies Questions & Answers

Plz Help in sorting the data on date basis

I have file having below data 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 IN 1514 0000764631 01-NOV-13 2.38.11.00.100089 IN 1514 0000856571 01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531 01-JUN-13 2.38.19.00.100000 IN 2698 0000764493 01-JUL-13... (2 Replies)
Discussion started by: ranabhavish
2 Replies

3. Shell Programming and Scripting

Need to Add date on first position.Plz help

We have a file as shown below with Header and details below Header.Here Header indicates date field. i Want to add date i.e 20100928 as a first position as shown below without header.Please help us using unix script Source file: H20100928 D04041201609360677PC790010384I ... (17 Replies)
Discussion started by: dprakash
17 Replies

4. Shell Programming and Scripting

Need-To remove header/trailor and add-date-on first-postion-plz-help

Hi Friends thanks a lot....for ur replies its worked fine...i have one more question.. if i need to remove trailor (T000000004 ) as shown below file also with header.Plz help thanks Source file: H20100928 D04041201609360677PC790010384I D04041203326357853PC790010645R ... (1 Reply)
Discussion started by: dprakash
1 Replies

5. Shell Programming and Scripting

Date function

I read man page for etc/shadow field.. on the 8th field, i assume that's the field to change account expire date. my question is: What value does the 8th field keep? i assume it's 13514 instead of "Date" value such as 11/10/08. on the man page, it said: " expire value = 13514 = jan 1,... (11 Replies)
Discussion started by: c00kie88
11 Replies

6. Shell Programming and Scripting

Date Function

Hi, My file format is: E102,0,21-04-2007,0,2/25/1994,E003,A,125400,10450,60.2884620 E103,0,21/04/2007,0,2/2/1996,E003,A,125400,10450,60.2884620 E104,0,04/21/2007,0,2/2/1996,E003,A,125400,10450,60.2884620 E105,0,21-APR-2007,0,2/2/1996,E003,A,125400,10450,60.2884620... (1 Reply)
Discussion started by: charandevu
1 Replies

7. Shell Programming and Scripting

Date Function

Hi, My file format is: E102,0,21-04-2007,0,2/25/1994,E003,A,125400,10450,60.2884620 E103,0,21/04/2007,0,2/2/1996,E003,A,125400,10450,60.2884620 E104,0,04/21/2007,0,2/2/1996,E003,A,125400,10450,60.2884620 E105,0,21-APR-2007,0,2/2/1996,E003,A,125400,10450,60.2884620... (1 Reply)
Discussion started by: charandevu
1 Replies

8. Shell Programming and Scripting

date function

hi, I have to ftp previous days file from a directory to another location. The name of the files are like "xxx20060225" (yyyymmdd format) "xxx20060226" ls -lrt xxx*| tail -2| head -1 will give me the file, but if i could get anything... (2 Replies)
Discussion started by: abey
2 Replies

9. UNIX for Dummies Questions & Answers

Date function question

hi guys! just want to ask if you could help me with the sript i'm working on. i need to automatically generate a summarized report everyday for all transactions the day before and ftp it to another machine. my only problem is that i need to name the file as the date yesterday. for example if i... (12 Replies)
Discussion started by: crpalermo
12 Replies

10. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies
Login or Register to Ask a Question