c**t 发帖数: 2744 | 1 I tried to get full date string of yesterday with format YYYYMMDD.
The following function works fine except the end of each month. Could
anybody tell me why? and how to fix?
Thanks
#!/usr/bin/ksh
GetDate ()
{
YESTERDAY=$((`date +%d` -1))
MONTH=`date +%m`
YEAR=`date +%Y`
if [ $YESTERDAY -eq "0" ]
then
MONTH=$((MONTH-1))
if [ $MONTH -eq "0" ]
then
MONTH=12
YEAR=$((YEAR-1))
fi
set `cal $MONTH $YEAR`
shift $(($# - 1))
|
t*u 发帖数: 186 | 2 i commented out "GetDate ()" and "{}", made it into a script, it works
correctly on my machine.
【在 c**t 的大作中提到】 : I tried to get full date string of yesterday with format YYYYMMDD. : The following function works fine except the end of each month. Could : anybody tell me why? and how to fix? : Thanks : #!/usr/bin/ksh : GetDate () : { : YESTERDAY=$((`date +%d` -1)) : MONTH=`date +%m` : YEAR=`date +%Y`
|
c**t 发帖数: 2744 | 3 Did you change your system date to 11/01/2003 or 10/01/2003?
As I stated it works fine except the last day of a month.
【在 t*u 的大作中提到】 : i commented out "GetDate ()" and "{}", made it into a script, it works : correctly on my machine.
|
t*u 发帖数: 186 | 4 yea, set the date to 10/01/2003, it prints "2003930".
【在 c**t 的大作中提到】 : Did you change your system date to 11/01/2003 or 10/01/2003? : As I stated it works fine except the last day of a month.
|