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

Josh Narins jnarins at seniorbridge.com
Wed Jan 26 22:13:54 EST 2011




yyyy-mm-dd works, but you'll want(need?) leading zeroes for mm and dd.


From: Chris Herrmann [mailto:chris.herrmann at faredge.com.au]
Sent: Wednesday, January 26, 2011 09:53 PM
To: rt-users at lists.bestpractical.com <rt-users at lists.bestpractical.com>
Subject: [rt-users] Passing date variables as dates from the CLI

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




Josh Narins
Director of Application Development

SeniorBridge
845 Third Ave
7th Floor
New York, NY 10022
Tel: (212) 994-6194
Fax: (212) 994-4260
Mobile: (917) 488-6248
jnarins at seniorbridge.com
seniorbridge.com<http://www.seniorbridge.com/>

[http://www.seniorbridge.com/images/seniorbridgedisclaimerTAG.gif]


________________________________
SeniorBridge Statement of Confidentiality: The contents of this email message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. Any dissemination, distribution or copying of this email by an unintended or mistaken recipient is strictly prohibited. In said event, kindly reply to the sender and destroy all entries of this message and any attachments from your system. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110126/6582d6f9/attachment.htm>


More information about the rt-users mailing list