Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Indrakumar Gowda Super Contributor.
Super Contributor.
486 views

Need a help in updating the Computer Assignment

Dear Experts,

Now i have to update the Server status, if it is not scanned for 40 days i have to "Retired" else I have to make the status as "In Use". for that im writing the script as below.

if [dtLastScan] > (getdate() - 40)
Then SET[Portfolio.seAssignment] = 0
Else SET[Portfolio.seAssignment] = 2ScriptError.JPG
end if

But im getting the error while executing this. please help

Indrakumar
0 Likes
6 Replies
Acclaimed Contributor.. Mark Cullen_1 Acclaimed Contributor..
Acclaimed Contributor..

Re: Need a help in updating the Computer Assignment

IF [dtLastScan] > (getdate() - 40) THEN
   SET[Portfolio.seAssignment] = 0
ELSE
   SET[Portfolio.seAssignment] = 2
END IF

Indrakumar Gowda Super Contributor.
Super Contributor.

Re: Need a help in updating the Computer Assignment

Thank you Mark for the correct Syntax. Now im getting the below error.

Sub or function 'getdate' not defined. ('Line 1 of script ''Update the Computer Assignment' of table 'IT equipment (amComputer)''')

But getdate() is working fine in filters and other screens.

Regards,

Indra

Indrakumar
0 Likes
Acclaimed Contributor.. Mark Cullen_1 Acclaimed Contributor..
Acclaimed Contributor..

Re: Need a help in updating the Computer Assignment

Yes, and those are the only places GetDate() works so use Date() instead or NOW() if you want date and time.

0 Likes
Highlighted
GoldenRatioRJP Honored Contributor.
Honored Contributor.

Re: Need a help in updating the Computer Assignment

GetDate() is an AQL Function not a Cypress Function.  So use Now() as Mark suggested.

Not sure just using "-40" will do what you want though since I think that will subtract 40 seconds not 40 days.

So try suptracting 40*86400 to get to days.  If that does not work look at the AmDateDiff() or AmDateAdd() functions.

Cheers....

Russell Parker, CITAM, CHAMP, CSAM
President - Golden Ratio, Inc.
Russ.Parker@GoldenRatioInc.com
0 Likes
Indrakumar Gowda Super Contributor.
Super Contributor.

Re: Need a help in updating the Computer Assignment

I have tried the Now() and Date() as Mark suggested, im getting the Type mismatch error

Indrakumar
0 Likes
Acclaimed Contributor.. Mark Cullen_1 Acclaimed Contributor..
Acclaimed Contributor..

Re: Need a help in updating the Computer Assignment

I assume the type mismatch relates with the date-time logic.  I would review Russell's post as well as the programmer's reference pdf guide for function definitions and section regarding date-time elements.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.