can I specifiy the start and end times manually

Hi

I have a ksh script which fetches data from a db using a number of .arc files and creates CSV files for them and puts them on the server.

Question is, can I specifiy the start and stop times manually and run the script manually to fetch data for a certain period?

# Get the current time as the stop time.

stoptime=`date +"%Y-%m-%d %H:00"`
if test $? -ne 0
then
   echo "Failed to get the date"
   rm -f $1/.optpamd.pid
   exit 4
fi

# Read the lasttime file to get the start time
# optlasttime contains the last time the database was
# successfully queried. The file is automatically created by
# this script

if test -f $1/optlasttime
then
   starttime=`cat $1/optlasttime`

# If the length of the chain is zero
# (lasttime is empty) it is updated properly
# and I wait for the following hour

   if test -z "$starttime"
   then
      echo "Empty file lasttime"
      echo $stoptime > $1/optlasttime
      rm -f $1/.optpamd.pid
      exit 5
   fi
else
   # If lasttime does not exist I create, it with the present date
   # and I wait for the following hour
   echo "File lasttime does not exist"
   echo $stoptime > $1/optlasttime
   rm -f $1/.optpamo.pid
   exit 6
fi

# Get a list of reports to run

while test "$starttime" != "$stoptime"
do

day=`echo $starttime | nawk '{ printf "%02d\n", substr($1,9,2)}'`
month=`echo $starttime | nawk '{ printf "%02d\n", substr($1,6,2)}'`
ano=`echo $starttime | nawk '{ printf "%02d\n", substr($1,1,4)}'`
hour=`echo ${starttime#* } | nawk '{ printf "%02d\n", substr($1,1,2)}'`
minute=`echo ${starttime#* } | nawk '{ printf "%02d\n", substr($1,4,2)}'`
more code to fetch data from db

# The interval superior of the date is the same that the inferior
# but increased 1 hour

endtime=$ano-$month-$day" "$hour":"$minute
ftime=$ano$month$day$hour$minute

#There are a number of '.arc' files per which this script fetches data from the db.

    #
      basename $rep
      datafile=$2/`basename $rep`.$ftime.csv
      rm -f $datafile
      touch $datafile

# For each report I execute its sentence SQL

for rep in $reports
   do

# Create Output file per each Measurement per hour

basename $rep
      datafile=$2/`basename $rep`.$ftime.csv
      rm -f $datafile
      touch $datafile

# Emptiness the files of compiled errors and reports

rm -f $1/aceerror
      rm -f $1/$rep.ace $1/$rep.arc
      
      echo "FROM :"$starttime"    TO :"$endtime"       STOPS:"$rep
  \# The hour changes
cat $rep.act | sed -e "s/STARTTIME/datetime($starttime) year to minute/" \
			 -e "s/ENDTIME/datetime($endtime) year to minute/" > $rep.ace

Any advice appreciated...Code too complex for me.