Wednesday, April 11, 2012

Determining durration between dates

I'm still pretty new to programming in BASH and i'm racking my brain on a problem. I'm trying to code a script for my work that would make it easy to calculate a refund on a given package cancelled before it's regular end date. Now the simple stuff like inputs and other such things I'm sure I can figure out with googling and experimentation (though should you choose to help with that I would be most appreciative).



What i'm not sure I could find how to do on my own is a script or set of commands that would be able to calculate the number of days / months between two dates and use that variable to calculate the total ammount of refund. I'll try and explain what I am trying to do here:



Input two dates (MM/DD/YYYY format) and get the difference in months and day, IE 3 months 13 days.



Input Base monthly rate



(Base * # of months) + ((base/30) * # of days) = Ammount customer used



Input how much customer payed - Ammount used = Ammount to be refunded



Then preferably it prints it in a manner that one could use to "show their work"



I know this is a bit much to ask for help with but I really could use a hand with the date calculator.



Thanks for any help in advance!



PS I did do a bit of searching beforehand and I found questions SIMILAR to this but nothing that really fit exactly what I needed.





No comments:

Post a Comment