- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scripting Help
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
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
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-19-2001 05:25 PM
10-19-2001 05:25 PM
I need help to calculate date difference.
Suppose if anyone pass two date then it should return actual day difference. It should calculate leap year also.
Like:
datediff.sh 25/01/2001 20/03/2001
It should return 55 days.
Pls help me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2001 06:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2001 06:37 PM
10-19-2001 06:37 PM
Re: Scripting Help
Using the caljd.sh script, this is a piece of cake. Believe me caljd.sh is pretty powerful dealing with dates, calculating different kind of dates/days of week. takes leap years in to consideration as well.
You could do something like,
/Begin/
#!/usr/bin/ksh
PATH=/usr/bin:/usr/local/bin
arg1=`echo $1 | sed 's/\// /g'`
arg2=`echo $2 | sed 's/\// /g'`
temp1=`caljd.sh $arg1`
temp2=`caljd.sh $arg2`
# temp2=`caljd.sh 03 20 2001`
# temp1=`caljd.sh 01 25 2001`
echo "$temp1-$temp2" | bc
/End/
This script will calculate the difference between the two arguments given to this program.
Remember to give the dates in the format mm/dd/yy
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2001 02:54 PM
10-20-2001 02:54 PM
Re: Scripting Help
Sine I posted caljd.sh, I have found a small but stupid bug on my part. I missed one integer divide and it evaluated to a floating point divide. This could lead to small errors but this version of caljd.sh corrects that.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2001 05:19 PM
10-21-2001 05:19 PM