The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Function to find day of any given date. RRVARMA Shell Programming and Scripting 5 05-12-2008 12:19 AM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 06:12 AM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 04:44 AM
Wrong date function Asteroid Shell Programming and Scripting 3 04-04-2007 01:09 AM
date function abey Shell Programming and Scripting 2 02-27-2006 02:28 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 07-20-2008
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
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
$
Reply With Quote
Forum Sponsor
  #9  
Old 07-21-2008
Registered User
 

Join Date: Sep 2007
Posts: 8
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.

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.

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

Thank you.
Reply With Quote
  #10  
Old 07-22-2008
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
Quote:
Originally Posted by pchang View Post
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.
.
Humm, what version of AIX are you using?
What is the output of "print $KSH_VERSION" and "print ${.sh.version}"
Reply With Quote
  #11  
Old 07-22-2008
Registered User
 

Join Date: Sep 2007
Posts: 8
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.
Reply With Quote
  #12  
Old 07-22-2008
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
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.
Reply With Quote
  #13  
Old 07-22-2008
Registered User
 

Join Date: Sep 2007
Posts: 8
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???
Reply With Quote
  #14  
Old 07-23-2008
Registered User
 

Join Date: Sep 2007
Posts: 8
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
date, datecalc, linux, shell script, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0