Thread: RE: [Arsperl-users] Querying by dates?
Brought to you by:
jeffmurphy
|
From: Lintner, M. <mit...@ci...> - 2005-10-13 18:44:44
|
Sorry, I have not done a lot of Perl for many years and I am very rusty
and most likely not up to date. You suggests are lost on me. I really
don't understand.
=20
Thanks,
=20
Mitch
=20
Mitch Lintner=20
Analyst/Programmer=20
Remedy Developer=20
Cingular Wireless=20
1125 E Campbell Rd=20
Richardson, Texas, 75081=20
972-907-6965=20
mit...@sw...=20
=20
________________________________
From: ars...@ar...
[mailto:ars...@ar...] On Behalf Of Richard Hellier
Sent: Thursday, October 13, 2005 1:30 PM
To: ars...@ar...
Subject: Re: [Arsperl-users] Querying by dates?
Mitch,
The short answer is: Remedy only understands one of your date
formats! I usually use dates like "20 September 2005" but you can just
embed the $TIMESTAMP$ "macro" if you want.
BTW, try using Perl's qq{} operator which allows you to create
double quoted strings without having to bother with escaping any
intervening double quotes.
Good Luck!
Richard.
Lintner, Mitchell wrote:=20
I am having trouble getting a ARSPERL script to query with
dates. Can you suggest what I am doing wrong?=20
$query =3D "('Approver CUID' =3D \"$approver_cuid\" AND 'Start Time'
<=3D \"$time\" AND 'End Time' >=3D \"$time\")";=20
%alternates=3Ddoquery($ctrl,$schema,$query);=20
If I give $time a value of "10/13/05 10:42:03", the script does
not find anything. If I set $time equal to 1129220941=20
It finds the necessary records.=20
I want to call this script from a Run Process and pass it the
$TIMESTAMP$ value.=20
|
|
From: Das, M. <md...@ti...> - 2005-10-13 19:28:50
|
Mitch,
How about this.
Before you do Run process
Do a setfield action and set $time-integer =3D $time (this will put
integer value in $time-integer (integer field you need to create))
=20
Now do
$query =3D "('Approver CUID' =3D \"$approver_cuid\" AND 'Start Time' =
<=3D
\"$time-integer \" AND 'End Time' >=3D \"$time-integer \")";=20
%alternates=3Ddoquery($ctrl,$schema,$query);=20
=20
=20
Thanks,
Mano
________________________________
From: ars...@ar...
[mailto:ars...@ar...] On Behalf Of Lintner, Mitchell
Sent: Thursday, October 13, 2005 12:49 PM
To: ars...@ar...
Subject: [Arsperl-users] Querying by dates?
I am having trouble getting a ARSPERL script to query with dates. Can
you suggest what I am doing wrong?=20
$query =3D "('Approver CUID' =3D \"$approver_cuid\" AND 'Start Time' =
<=3D
\"$time\" AND 'End Time' >=3D \"$time\")";=20
%alternates=3Ddoquery($ctrl,$schema,$query);=20
If I give $time a value of "10/13/05 10:42:03", the script does not find
anything. If I set $time equal to 1129220941=20
It finds the necessary records.=20
I want to call this script from a Run Process and pass it the
$TIMESTAMP$ value.=20
Thanks,=20
Mitch=20
Mitch Lintner=20
Analyst/Programmer=20
Remedy Developer=20
Cingular Wireless=20
1125 E Campbell Rd=20
Richardson, Texas, 75081=20
972-907-6965=20
mit...@sw...=20
|
|
From: Lintner, M. <mit...@ci...> - 2005-10-13 19:32:43
|
Thanks,
=20
I just did do this and it works fine.
=20
Mitch Lintner=20
Analyst/Programmer=20
Remedy Developer=20
Cingular Wireless=20
1125 E Campbell Rd=20
Richardson, Texas, 75081=20
972-907-6965=20
mit...@sw...=20
=20
________________________________
From: ars...@ar...
[mailto:ars...@ar...] On Behalf Of Das, Manojit
Sent: Thursday, October 13, 2005 2:28 PM
To: ars...@ar...
Subject: RE: [Arsperl-users] Querying by dates?
Mitch,
How about this.
Before you do Run process
Do a setfield action and set $time-integer =3D $time (this will put
integer value in $time-integer (integer field you need to create))
=20
Now do
$query =3D "('Approver CUID' =3D \"$approver_cuid\" AND 'Start Time' =
<=3D
\"$time-integer \" AND 'End Time' >=3D \"$time-integer \")";=20
%alternates=3Ddoquery($ctrl,$schema,$query);=20
=20
=20
Thanks,
Mano
________________________________
From: ars...@ar...
[mailto:ars...@ar...] On Behalf Of Lintner, Mitchell
Sent: Thursday, October 13, 2005 12:49 PM
To: ars...@ar...
Subject: [Arsperl-users] Querying by dates?
I am having trouble getting a ARSPERL script to query with dates. Can
you suggest what I am doing wrong?=20
$query =3D "('Approver CUID' =3D \"$approver_cuid\" AND 'Start Time' =
<=3D
\"$time\" AND 'End Time' >=3D \"$time\")";=20
%alternates=3Ddoquery($ctrl,$schema,$query);=20
If I give $time a value of "10/13/05 10:42:03", the script does not find
anything. If I set $time equal to 1129220941=20
It finds the necessary records.=20
I want to call this script from a Run Process and pass it the
$TIMESTAMP$ value.=20
Thanks,=20
Mitch=20
Mitch Lintner=20
Analyst/Programmer=20
Remedy Developer=20
Cingular Wireless=20
1125 E Campbell Rd=20
Richardson, Texas, 75081=20
972-907-6965=20
mit...@sw...=20
|
|
From: Carey M. B. <bla...@gm...> - 2005-10-13 19:46:49
|
Mitch,
Let us first start with general issues then. :)
When you call the command line script make sure you pass the
$TIMESTAMP$ keyword in single quotes. This should get the value to
Perl in one command line variable. (Note if your using a windows box,
then you might have to go with double quotes.) If you do not do that
the the Perl script might be getting multiple command line values that
are the TIMESTAMP value as a whole.
@[0]=3D"10/13/05"
@[1]=3D"10:42:03"
(Which could also be confusing some issues for what records are selected to=
o.)
Now once you have the right string in a single Perl variable then you
have a few choices to make.
1) Do you want to parse any incoming data formats and only pass GMT
epoch seconds values back to the ARS server? (This is likely the "most
general" way to do these things.)
If so.. look at the Perl Date::Manip module. Lots of good stuff in
there. Most specifically:
use Date::Manip;
$date =3D ParseDate($string);
$secs =3D &UnixDate($date,"%s");
$time=3D$secs; # for your variable names. :)
# ParseDate does some very cool things see the perlpod for full
details, but here are a few examples
# $date =3D ParseDate("today");
# $date =3D ParseDate("1st thursday in June 1992");
# $date =3D ParseDate("05/10/93");
# $date =3D ParseDate("12:30 Dec 12th 1880");
# $date =3D ParseDate("8:00pm december tenth");
2) Do you want to "trust" the format of the time value as is? (This is
likely the least productive way to do this, but allows control of
these issues to be outside the Perl script too. And you may need to
deal with error handling and such when you find no matching records or
get other errors back from the ARSPerl/ARS API layers.)
3) Was the TimeZone of the value being passed the same as the TimeZone
of where the script is being run? (You might need to find a way to
figure that out in the script and adjust the value. However if the
TIMESTAMP is from the ARS server and the script is running on the ARS
server then they should evaluate to be "the same". Well as long as the
Perl script has access to the same settings that was used to start
your ARS server. :)
Oh... and the qq comment was a suggestion to use syntax like the following:
# qq then a pipe symbol delimited value.
# The basic value here is that Perl will "protect" and quotes and
stuff that needs protected and return the whole value as you would=20
expect if you had no idea what \" should do, or why a double quote
inside a double quoted value was a problem. :)
$query =3D qq|'Approver CUID' =3D "$approver_cuid" AND 'Start Time' <=3D
"$time" AND 'End Time' >=3D "$time"|;
%alternates=3Ddoquery($ctrl,$schema,$query);
HTH.
--
Carey Matthew Black
Remedy Skilled Professional (RSP)
ARS =3D Action Request System(Remedy)
Solution =3D People + Process + Tools
Fast, Accurate, Cheap.... Pick two.
Never ascribe to malice, that which can be explained by incompetence.
On 10/13/05, Lintner, Mitchell <mit...@ci...> wrote:
>
> Sorry, I have not done a lot of Perl for many years and I am very rusty a=
nd
> most likely not up to date. You suggests are lost on me. I really don't
> understand.
>
> Thanks,
>
> Mitch
>
>
> Mitch Lintner
> Analyst/Programmer
> Remedy Developer
> Cingular Wireless
> 1125 E Campbell Rd
> Richardson, Texas, 75081
> 972-907-6965
> mit...@sw...
>
>
> ________________________________
> From: ars...@ar...
> [mailto:ars...@ar...] On Behalf Of Richard Hellier
> Sent: Thursday, October 13, 2005 1:30 PM
> To: ars...@ar...
> Subject: Re: [Arsperl-users] Querying by dates?
>
>
> Mitch,
> The short answer is: Remedy only understands one of your date format=
s!
> I usually use dates like "20 September 2005" but you can just embed the
> $TIMESTAMP$ "macro" if you want.
>
> BTW, try using Perl's qq{} operator which allows you to create double
> quoted strings without having to bother with escaping any intervening dou=
ble
> quotes.
>
> Good Luck!
>
> Richard.
>
>
> Lintner, Mitchell wrote:
>
>
>
> I am having trouble getting a ARSPERL script to query with dates. Can you
> suggest what I am doing wrong?
>
> $query =3D "('Approver CUID' =3D \"$approver_cuid\" AND 'Start Time' <=3D
> \"$time\" AND 'End Time' >=3D \"$time\")";
> %alternates=3Ddoquery($ctrl,$schema,$query);
>
> If I give $time a value of "10/13/05 10:42:03", the script does not find
> anything. If I set $time equal to 1129220941
> It finds the necessary records.
>
> I want to call this script from a Run Process and pass it the $TIMESTAMP$
> value.
|