Routines (alphabetical) > Routines: C > CDF Routines > CDF_EPOCH_COMPARE

# CDF_EPOCH_COMPARE

The CDF_EPOCH_COMPARE function compares two epoch (date and time) values.

Values can be scalars or an array of values. The epoch can be one of the CDF formats, CDF_EPOCH, CDF_EPOCH16 or CDF_TIME_TT2000. While data of type CDF_EPOCH and CDF_EPOCH16 can be compared with each other, data in CDF_TIME_TT2000 can be compared only with data of the same type.

If the base epoch is a scalar, it is used to compare with all values in the first epoch. If the base epoch is an array, the same element in the source and base epoch array is compared. If a third argument, endepoch, is provided, the baseepoch and endepoch are used as the starting and ending epoch that the source epoch will be checked against.

## Examples

; For CDF_EPOCH data type

CDF_VARGET, id, "Epoch", ep, REC_COUNT=1000,/ZVARIABLE

CDF_EPOCH, base, 2005,6,1,10,18,17,2,/COMPUTE

ret= CDF_EPOCH_COMPARE(ep,base)

HELP, ret

; For CDF_TIME_TT2000 data type

CDF_VARGET, id2, "Epoch", ep2, REC_COUNT=1000,/ZVARIABLE

CDF_TT2000, base2, 2005,6,1,10,18,17,2,3,4,/COMPUTE

ret2= CDF_EPOCH_COMPARE(ep2,base2)

HELP, ret2

; For CDF_EPOCH data type

CDF_VARGET, id3, "Epoch", ep3, REC_COUNT=1000,/ZVARIABLE

CDF_EPOCH, starting, 2005,6,1,10,18,17,2,/COMPUTE

CDF_EPOCH, ending, 2005,6,10,10,18,17,2,/COMPUTE

ret3= CDF_EPOCH_COMPARE(ep3,starting,ending)

HELP, ret3

## Syntax

Result = CDF_EPOCH_COMPARE(epoch, baseepoch, [end epoch])

## Return Value

### Using Two Arguments

If the function uses two arguments, the return value is a scalar value or an array of integer values (1, 0, or -1), depending on the source epoch.

If the value of the first epoch is greater (later date and time) than the base epoch, 1 is set.

If the value of the first epoch is the same as the base epoch, 0 is set.

If the value of the first epoch is less (earlier date and time) than the base epoch, -1 is set.

Result | Condition
--- | ---
1 | if epoch1 > baseepoch
0 | if epoch1 = baseepoch
-1 | if epoch1 < baseepoch

### Using Three Arguments

If the function uses three arguments, the return value is a scalar value or an array of integer values (1 or 0).

If the value of the source epoch falls within the starting and ending epoch, 1 is set. Otherwise, 0 is set.

1 | if baseepoch <= epoch1 <= endepoch
0 | Otherwise

## Arguments

### epoch

A single or an array of epoch value(s) returned from:

- CDF_EPOCH,/compute, CDF_EPOCH16,/compute for CDF_EPOCH or CDF_EPOCH16 data type
- CDF_TT2000,/compute for CDF_TIME_TT2000 data type
- CDF_VARGET, or CDF_VARGET1

### baseepoch

A single or an array of epoch value(s) returned from:

- CDF_EPOCH,/compute, CDF_EPOCH16,/compute for CDF_EPOCH or CDF_EPOCH16 data type
- CDF_TT2000,/compute for CDF_TIME_TT2000 data type
- CDF_VARGET, or CDF_VARGET1

### endepoch

A single or an array of epoch value(s) returned from:

- CDF_EPOCH,/compute, CDF_EPOCH16,/compute for CDF_EPOCH or CDF_EPOCH16 data type
- CDF_TT2000,/compute for CDF_TIME_TT2000 data type
- CDF_VARGET, or CDF_VARGET1

Note: This field must be of the same data type and dimensionality as baseepoch.

## Keywords

None

## Version History

6.4 | Introduced