mindful07 has asked for the wisdom of the Perl Monks concerning the following question:
How do you subtract two dates (both in the format of YYYYMMDD) to obtain the value in days? One date will always be local date and I'm using strftime("%Y%m%d", localtime(time) to obtain it. I do not have nor can I use the Time:Piece or Date:Calc modules at this time. The problem I am having is as long as its the same year (for example 20070108 - 20070101) my code will work fine giving me 7 days. But if I have 20070108 - 20061228 it will return an incorrect amount of days.
My second issue is once I get the amount of days it doesnt appear that I'm able to compare it. I have a variable called $diff_days that returns 7. I then want to compare $diff_days > 15 or $diff_days = 15. Is that possible? What is the best way to handle that because I get a syntax error.
Could you please provide examples since I am very new to Perl.
|
|---|