Hi all,
I'm trying to use "date" to calculate some dates. I'm getting some wrong results and wonder, if I'm doing something wrong here. If someone has any idea or if your "date" works as expected, please post here. In case it works on your machine could you please tell me which version of coreutils you have installed?
The example code I'm using follows. I first create a date, which should switch to a previous day if I substract some minutes.
The code and the results I get:
Code:
bash-3.1$ REC_YEAR=2009
bash-3.1$ REC_MONTH=9
bash-3.1$ REC_DAY=1
bash-3.1$ REC_HOUR=0
bash-3.1$ REC_MIN=3
bash-3.1$ date -d "$REC_YEAR-$REC_MONTH-$REC_DAY $REC_HOUR:$REC_MIN" +"%d.%m.%Y %H.%M"
01.09.2009 00.03
bash-3.1$ date -d "$REC_YEAR-$REC_MONTH-$REC_DAY $REC_HOUR:$REC_MIN -5 minutes" +"%d.%m.%Y %H.%M"
01.09.2009 07.04 # <- coreutils version 7.4
bash-3.1$ date -d "$REC_YEAR-$REC_MONTH-$REC_DAY $REC_HOUR:$REC_MIN -5 minutes" +"%d.%m.%Y %H.%M"
01.09.2009 02.09 # <- coreutils version 6.12
To try it out, just the code:
Code:
REC_YEAR=2009
REC_MONTH=9
REC_DAY=1
REC_HOUR=0
REC_MIN=3
date -d "$REC_YEAR-$REC_MONTH-$REC_DAY $REC_HOUR:$REC_MIN" +"%d.%m.%Y %H.%M"
date -d "$REC_YEAR-$REC_MONTH-$REC_DAY $REC_HOUR:$REC_MIN -5 minutes" +"%d.%m.%Y %H.%M"
Thanks for reading my post and any replies!