[rt-users] Passing date variables as dates from the CLI

Chris Herrmann chris.herrmann at faredge.com.au
Wed Jan 26 21:53:48 EST 2011


Hi all,

Another problem to do with (I suspect) dates not be treated as dates.

My script has this block at the front to set some variables, so that I can eventually run it from a regular cron job:

startmonth=`date +%m`
startyear=`date +%Y`
endyear=$startyear
friendlymonth=`date +%b`
reportperiod=$friendlymonth" "$startyear
if [ $startmonth = 12 ];then
               endyear=$(($startyear+1))
               endmonth=1
else
               endyear=$startyear
               endmonth=$(($startmonth+1))
fi
startdate=1/$startmonth/$startyear
enddate=1/$endmonth/$endyear

Idea being to put the start & end dates into variables "startdate" and "enddate" to restrict the report range.

If I run:

               rt list "queue = 'myqueue' and created > '$startdate'"

It returns results correctly.

If I run:
               rt list "queue = 'myqueue' and created < '$enddate'"

It says "No matches found".

If I manually enter:

                              rt list "queue = 'myqueue' and created < '1/2/2011'"

Then it works correctly.

root at sirius:/ # echo $startdate $enddate
1/01/2011 1/2/2011

They're obviously different - "startdate" has a month of "01" whilst "enddate" is "2". But startdate works, and enddate not...

Is there some way I need to format the resulting variable differently so that it knows it's a date and is treated as such?

Thanks,

Chris Herrmann
Far Edge Technology

p. 02 84251400
m. 0403 393309
http://www.faredge.com.au

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110127/e9073c9d/attachment.htm>


More information about the rt-users mailing list