Strange Date Issue (560 Views)
Reply
Regular Advisor
DV_2
Posts: 132
Registered: ‎12-01-2009
Message 1 of 6 (560 Views)

Strange Date Issue

Hi,

 

I'm facing a very strange issue with the date validation. 

 

I have a condition in change that request end date should be greater than 5 days. 

 

In cm3r fc, I have a validation to find this and its working fine. 

 

Now am trying to set this condition while escalating it from interaction. I added similar condition in wizard.escalation.rfc

On Add: true, validation: $requested.end.date>=tod()+'5 00:00:00' 

 

But this condition is not working rather i would say returns wrong value. 

 

This is the RAD debugger output. 

 

>d $requested.end.date>=tod()+'5 00:00:00'

true

 

>d $requested.end.date

29/09/11 00:00:00

 

>d tod()+'5 00:00:00'

02/10/11 12:53:38

 

>d '29/09/11 00:00:00'>='02/10/11 00:00:00'

false

 

The calculation $requested.end.date>=tod()+'5 00:00:00' should be false as reuqest end date is just 2 days from today. But when i give the date directly it returns correct result(false)

 

Any idea why this is.... and how to fix this....?

 

Regards,

DV

 

Please use plain text.
Valued Contributor
JD_Jinesta
Posts: 67
Registered: ‎07-05-2011
Message 2 of 6 (547 Views)

Re: Strange Date Issue

Hi DV,

 

It's possible that the variable holds a different datatype that datetime so when it's compared against a datetime value it's not doing it properly.

 

Type() function can confirm datatype and Try using val() function to convert $requested.end.date to datetime, e.g. val($requested.end.date)

 

Good Luck,

SM Support Engineer

Thank you for using the HPSW forums. If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.
Please use plain text.
Honored Contributor
-m-
Posts: 989
Registered: ‎02-22-2011
Message 3 of 6 (537 Views)

Re: Strange Date Issue

The RAD function to check the data-type is actually lower-case...

 

RAD Debugger example:

d type($requested.end.date)

 

Common data-types:

1 = number

2 = character

3 = date/time

4 = logical

6 = record

8 = array

9 = structure

 

Please use plain text.
Honored Contributor
James Herold
Posts: 861
Registered: ‎07-20-2006
Message 4 of 6 (512 Views)

Re: Strange Date Issue

I'm assuming you're using dd/mm/yyyy format.  When you list your debugger session

 

This is the RAD debugger output. 

 

>d $requested.end.date>=tod()+'5 00:00:00'

true

 

>d $requested.end.date

29/09/11 00:00:00

 

>d tod()+'5 00:00:00'

02/10/11 12:53:38

 

>d '29/09/11 00:00:00'>='02/10/11 00:00:00'

false

... the last statement is correct.  September 29 is not greater than or equal October 2

 

Have you tried initializing your variable before it's assigned?  Since you're trying to check for 5 days in the future, your routine could simply set it to $requested.end.date=tod()

 

You may also want to use the 'x' command in your debugger session to check.

 

>x $required.end.date=tod()+'5 00:00:00'
11/26/11 15:00:37
>x $requested.end.date=tod()+4 00:00:00'
11/21/11 15:05:08
>d evaluate($requested.end.date>$required.end.date)
false
>d evaluate($requested.end.date<$required.end.date)
true


Please use plain text.
Occasional Advisor
fespil
Posts: 9
Registered: ‎10-31-2011
Message 5 of 6 (228 Views)

Re: Strange Date Issue

In RAD debugger:

 

d tod() < val($var_name,3)

 

Now you are comparing the actual date (in date format) with a variable (in date format).

 

From the programming guide:

 

Primitive data types consist of one element. Service Manager internally represents each data type
by its numeric representation. Certain functions ( val() and type() ) allow the user to determine
or modify the numeric representation of a data type, thus changing the data type.

 

Regards, Federico.-

Please use plain text.
HP Expert
FrankRen
Posts: 23
Registered: ‎03-18-2014
Message 6 of 6 (187 Views)

Re: Strange Date Issue

This is a known defect which is fixed by QCCR1E80371 Queries with date/time calculations fail on SM systems converted to Oracle

 

That CR added a new RAD function datecmp("DateTimeField1","LogicOperator","DateTimeField2","+/-", "TimeInterval",), e.g. datecmp("close.time", "<", "open.time","+", "1 04:02:30"). It will be translated to the correct SQL statement dialect by translateDateCondition().

 

Here is examples about usage:

Tested on my PC and linux, with sqlserver, oracle, db2 and oob test incidents data.

 
1. Launch an Eclipse client and login as falcon
2. System Navigator - Menu Navigation - Incident Management - Search Incidents
3. Options - Expert Search
4. Execute the following query:
 
1)problem.status="Closed"  and datecmp("close.time","<","open.time","+","04:02:30") and datecmp("close.time",">=","open.time","+","02:02:30", )
only incidents whose closed time is between 2hours and 4 hours after the open time will be fetch and displayed.
 
2)problem.status="Closed"  and datecmp("open.time",">","close.time", "-", "04:02:30" ) and datecmp("close.time",">=","open.time","+","02:02:30" )
The same as 1)
 
3)problem.status="Closed"  and datecmp("close.time",">", "open.time", "+","31 04:02:30")
Incidents closed after more than 31 days since the open time will be displayed.
 
5. For JS test:
var f = new SCFile('probsummary', SCFILE_READONLY);
var query = 'problem.status="Closed" and datecmp("close.time", "<", "open.time","+", "04:02:30") and datecmp("close.time",">=", "open.time","+", "02:02:30")';
if (RC_SUCCESS == f.doSelect(query))
{
  do
  {
    print(f);
  }
  while (RC_SUCCESS == f.getNext());
};
 
 
And another test from the QA:
Exploratory Test: Test for search changes.
Expert Search query: status#"i" and datecmp("planned.start","<","planned.end","-","10 01:30:0") and datecmp("planned.end",">=","planned.start","+","5")
>> changes which status start with "i", planned.start and planned.end between 5 days and around 10 days will be displayed.
 
Use JavaScript&colon;
var f = new SCFile('cm3r', SCFILE_READONLY);
var query = 'status#"i" and datecmp("planned.start","<","planned.end","-","10 01:30:0") and datecmp("planned.end",">=","planned.start","+","5")';
if (RC_SUCCESS == f.doSelect(query))
{
  do
  {
    print( f);
  }
  while (RC_SUCCESS == f.getNext( ));
};
>> same result as that of Expert Search

 
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation