Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_time_date_string_compare (x05ac)

## Purpose

nag_time_date_string_compare (x05ac) compares two date/time character strings, each stored in the format returned by nag_time_date_array_string (x05ab).

## Syntax

[result] = x05ac(ctime1, ctime2)
[result] = nag_time_date_string_compare(ctime1, ctime2)

## Description

nag_time_date_string_compare (x05ac) compares two date/time character strings, and returns an integer that specifies which one is the earliest. The result is an integer returned through the function name, with meaning as follows:
• if nag_time_date_string_compare (x05ac) = 1$\text{}=-1$, the first date/time string is earlier than the second;
• if nag_time_date_string_compare (x05ac) = 0$\text{}=0$, the two date/time strings are equivalent;
• if nag_time_date_string_compare (x05ac) = 1$\text{}=1$, the first date/time string is later than the second.

None.

## Parameters

### Compulsory Input Parameters

1:     ctime1 – string
2:     ctime2 – string
The date/time strings to be compared. These are expected be in the format returned by nag_time_date_array_string (x05ab), although nag_time_date_string_compare (x05ac) will still attempt to interpret the strings if they vary slightly from this format. See Section [Further Comments] for further details.

None.

None.

### Output Parameters

1:     result – int64int32nag_int scalar
The result of the function.

None.

## Accuracy

Not applicable.

For flexibility, nag_time_date_string_compare (x05ac) will accept various formats for the two date/time strings ctime1 and ctime2.
The strings do not have to be the same length. It is permissible, for example, to enter with one or both of the strings truncated to a smaller length, in which case missing fields are treated as zero.
Each character string may be of any length, but everything after character 80$80$ is ignored.
Each string may or may not include an alphabetic day name, such as ‘Wednesday’, at its start. These day names are ignored, and no check is made that the day name corresponds correctly to the rest of the date.
The month name may contain any number of characters provided it uniquely identifies the month, however all characters that are supplied are significant.
Fields in the character string must be separated by one or more spaces.
The case of all alphabetic characters is not significant.
Any field in a date time string that is indecipherable according to the above rules will be converted to a zero value internally. Thus two strings that are completely indecipherable will compare equal.
According to these rules, all the following date/time strings are equivalent:
• ‘Thursday 10th July 1958 12:43:17.320’
• ‘THU 10th JULY 1958 12:43:17.320’
• ‘10th Jul 1958 12:43:17.320’

## Example

```function nag_time_date_string_compare_example
ctime1 = 'Thu 27th April 1989 13:15:21.320                  ';
ctime2 = 'Wed 26th April 1989 11:23:14.130                  ';
[result] = nag_time_date_string_compare(ctime1, ctime2)
```
```

result =

1

```
```function x05ac_example
ctime1 = 'Thu 27th April 1989 13:15:21.320                  ';
ctime2 = 'Wed 26th April 1989 11:23:14.130                  ';
[result] = x05ac(ctime1, ctime2)
```
```

result =

1

```