Skip to main content

1E SDK

COMPAREVERSIONS

Function

COMPAREVERSIONS

Action

Compare two version strings.

Parameters

(string) Version string 1 of the form major[.minor[.release[.build]]] where "7.3.2.8", "5.7.1", "2.29" and "14" are all valid version strings.

(string) Version string 2 of the formmajor[.minor[.release[.build]]]

Return values

(integer) An integer value representing the result of the first version string relative to the second:

-4 If the first version string's major is lower than the second version string's

-3 if the first is lower but major is the same

-2 if the first is lower but major.minor is the same

-1 if the first is lower but major.minor.release is the same

0 if the same

1 if the first is higher but major.minor.release is the same

2 if the first is higher but major.minor is the same

3 if the first is higher but major is the same

4 if the first's major is higher

Note

If an invalid version string is supplied then a null value is returned.

"Missing" fields are treated as numerically 0.

Examples

@a = Software.GetInstallations();
@b = select * from @a where Product like "Oracle VM VirtualBox";
select * from @b WHERE compareversions(@b.version, "5.1.2.14" ) < 0; 

Finds VirtualBox packages that are older than 5.1.2.14.