Open topic with navigation

TIBCO Rendezvous® 8.7.0

# Get DateTime

Convenience Method

## Declaration

    TibrvStatus getDateTime(
        const char*          fieldName,
        TibrvMsgDateTime&    value,
        tibrv_u16            fieldId=0);

## Purpose

Get the value of a field as an datetime value.

## Remarks

This convenience method retrieves a field and extracts its data.

Since it is not possible to convert any other datatype to a datetime value, the field must already contain a datetime. Otherwise, the method returns TIBRV_CONVERSION_FAILED.

Pointer data extracted from the field remain valid until the message is destroyed; that is, even removing the field or updating the field’s value does not invalidate pointer data.

This method produces values that are read-only snapshots of the field data (see Pointer Snapshot). Programs must not modify the datetime value.

Parameter | Description
`fieldName` | Get a field with this name.
`value` | The program supplies a variable in this parameter, and the method stores the field value in that variable.
`fieldId` | Get the field with this identifier. Zero is a special value that signifies no field identifier. All non-zero field identifiers must be unique within each message.

## Example

This example code extracts a datetime value from a message field, and converts it to a `time_t` value. Programs can adapt this code as appropriate. (For corresponding code to convert a `time_t` value to a datetime value, and add the datetime to a message field, see the example at Add DateTime.)

    #include <limits.h>
    TibrvStatus getAsTimeT(
           TibrvMsg& msg,
           const char* field,
           time_t& value)
    {
        TibrvMsgDateTime d;
        TibrvStatus error;
        error = msg.getDateTime(field,d);
        if (error != TIBRV_OK)
          return error;
        if (d.sec > INT_MAX || d.sec < INT_MIN)
          return TIBRV_CONVERSION_FAILED;
        value = (time_t)d.sec;
    }

## See Also

Validity of Data Extracted From Message Fields

Field Names and Field Identifiers

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO Rendezvous®

Copyright © 1997-2023. Cloud Software Group, Inc. All Rights Reserved.