- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Fiscal Date Shell Script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2006 09:35 AM
тАО10-20-2006 09:35 AM
Have the following script:
echo "This is a date test"
yearlong=$(date +%Y)
yearshort=$(date +%y)
echo "Year short --> " $yearshort
yearshort=$(($yearshort+1))
#if [ $yearshort -lt 10 ]
#then
# echo "less than 10 " $yearshort
# yearshort =$(string "0"+$yearshort)
# exit
#fi
echo "The fiscal date is $yearlong-$yearshort"
~
The fiscal date ends up as 2006-7.
How can I get the extra zero in the fiscal date? Trying to get the fiscal year to feed a
dbaccess query thru a script.
Monte.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2006 09:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2006 10:04 AM
тАО10-20-2006 10:04 AM
Re: Fiscal Date Shell Script
The easy way is to use formatted printing:
# printf "The fiscal date is %d-%02d\n" $yearlong $yearshort
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2006 11:02 AM
тАО10-20-2006 11:02 AM
Re: Fiscal Date Shell Script
yearlong=$(date +%Y)
yearshort=$(date +%y)
echo "Year short --> " $yearshort
yearshort=$(($yearshort+1))
if [ $yearshort -lt 10 ]
then
echo "The fiscal date is $yearlong-0$yearshort"
else
echo "The fiscal date is $yearlong-$yearshort"
fi
exit
Yang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2006 01:22 PM
тАО10-20-2006 01:22 PM
Re: Fiscal Date Shell Script
typeset -Z2 yearshort
yearshort=$(date +%y)
echo $yearshort
typeset has a *lot* of formatting features for variables (UPPERCASE, lowercase, leading zeros, leading spaces, trailing spaces, etc)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2006 05:44 AM
тАО10-21-2006 05:44 AM
Re: Fiscal Date Shell Script
based on Mr. Hassel's suggestion:
$ eval typeset -Z2 X=$(($(date +%y ) + 1)); date +%Y-${X}
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2006 09:43 AM
тАО10-24-2006 09:43 AM
Re: Fiscal Date Shell Script
Could not get the typeset example to work.
Please close this thread!
This is definitely a valueable resource center!
Monte.