

InterviewSolution
Saved Bookmarks
1. |
Solve : Adding or subtracting days from current date in batch script? |
Answer» <html><body><p>Hi,<br/><br/>I'm writing an batch file to create report<br/><br/>In the batch file iam <a href="https://interviewquestions.tuteehub.com/tag/passing-1148520" style="font-weight:bold;" target="_blank" title="Click to know more about PASSING">PASSING</a> two arguments:startdate and finishdate<br/><br/>Ex: startdate=07-sep-2009 finishdate=07-sep-2011<br/><br/>I <a href="https://interviewquestions.tuteehub.com/tag/need-25476" style="font-weight:bold;" target="_blank" title="Click to know more about NEED">NEED</a> to have script that takes command line argument as input and gives me out currentdate last <a href="https://interviewquestions.tuteehub.com/tag/year-247323" style="font-weight:bold;" target="_blank" title="Click to know more about YEAR">YEAR</a> and current date next year as mention above example.<br/><br/>currentdate-1 year &<a href="https://interviewquestions.tuteehub.com/tag/amp-363144" style="font-weight:bold;" target="_blank" title="Click to know more about AMP">AMP</a>; currentdate+ 1year<br/><br/>For example if I pass argument as 07-sep-2010 to batch script I should get ouput as startdate=07-sep-2009 finishdate=07-sep-2011.<br/><br/>Could any one please help?.<br/><br/>Regards,<br/>Anand<br/>you can download <a href="http://gnuwin32.sourceforge.net/packages/coreutils.htm"> coreutils </a> for windows, then use the date command<br/> Code: <a>[Select]</a>c:\test&<a href="https://interviewquestions.tuteehub.com/tag/gt-249387" style="font-weight:bold;" target="_blank" title="Click to know more about GT">GT</a>; gnu_date.exe -d "1 year ago"<br/>c:\test> gnu_date.exe -d "1 year"<br/><br/></p></body></html> | |