{
  "schema_version": 2,
  "id": "commands/hexpireat",
  "title": "HEXPIREAT",
  "url": "https://redis.io/docs/latest/commands/hexpireat/",
  "summary": "Set expiration for hash fields using an absolute Unix timestamp (seconds)",
  "since": "7.4.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:47:41+01:00",
  "page_type": "content",
  "content_hash": "5bcb19aa93d11437625f9ff71ba4c02c8ce17ff8ea3d5b439be2df204ed01d08",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "`HEXPIREAT` has the same effect and semantics as [`HEXPIRE`](https://redis.io/docs/latest/commands/hexpire), but instead of\nspecifying the number of seconds for the TTL (time to live), it takes\nan absolute [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time) in seconds since Unix epoch. A\ntimestamp in the past will delete the field immediately.\n\nFor the specific semantics of the command, see [`HEXPIRE`](https://redis.io/docs/latest/commands/hexpire)."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the hash.\n\n</details>\n\n<details open><summary><code>unix-time-seconds</code></summary>\n\nThe absolute Unix expiration timestamp, in seconds since Unix epoch. A timestamp in the past deletes the field immediately.\n\n</details>\n\n<details open><summary><code>FIELDS numfields field [field ...]</code></summary>\n\nThe hash fields to set expiration for. `numfields` is the number of fields, followed by that many field names.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "The following options modify the command's behavior. They are mutually exclusive.\n\n<details open><summary><code>NX</code></summary>\n\nFor each specified field, set expiration only when the field has no expiration.\n\n</details>\n\n<details open><summary><code>XX</code></summary>\n\nFor each specified field, set expiration only when the field has an existing expiration.\n\n</details>\n\n<details open><summary><code>GT</code></summary>\n\nFor each specified field, set expiration only when the new expiration is greater than the current one. A non-volatile key is treated as an infinite TTL for the purposes of `GT`.\n\n</details>\n\n<details open><summary><code>LT</code></summary>\n\nFor each specified field, set expiration only when the new expiration is less than the current one. A non-volatile key is treated as an infinite TTL for the purposes of `LT`.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Array reply](../../develop/reference/protocol-spec#arrays). For each field:\n    - [Integer reply](../../develop/reference/protocol-spec#integers): `-2` if no such field exists in the provided hash key, or the provided key does not exist.\n    - [Integer reply](../../develop/reference/protocol-spec#integers): `0` if the specified NX, XX, GT, or LT condition has not been met.\n    - [Integer reply](../../develop/reference/protocol-spec#integers): `1` if the expiration time was set/updated.\n    - [Integer reply](../../develop/reference/protocol-spec#integers): `2` when `HEXPIRE` or `HPEXPIRE` is called with 0 seconds or milliseconds, or when `HEXPIREAT` or `HPEXPIREAT` is called with a past Unix time in seconds or milliseconds.\n* [Simple error reply](../../develop/reference/protocol-spec#simple-errors):\n    - if parsing failed, mandatory arguments are missing, unknown arguments are specified, or argument values are of the wrong type or out of range.\n    - if the provided key exists but is not a hash.\n\n**RESP3:**\n\nOne of the following:\n* [Array reply](../../develop/reference/protocol-spec#arrays). For each field:\n    - [Integer reply](../../develop/reference/protocol-spec#integers): `-2` if no such field exists in the provided hash key, or the provided key does not exist.\n    - [Integer reply](../../develop/reference/protocol-spec#integers): `0` if the specified NX, XX, GT, or LT condition has not been met.\n    - [Integer reply](../../develop/reference/protocol-spec#integers): `1` if the expiration time was set/updated.\n    - [Integer reply](../../develop/reference/protocol-spec#integers): `2` when `HEXPIRE` or `HPEXPIRE` is called with 0 seconds or milliseconds, or when `HEXPIREAT` or `HPEXPIREAT` is called with a past Unix time in seconds or milliseconds.\n* [Simple error reply](../../develop/reference/protocol-spec#simple-errors):\n    - if parsing failed, mandatory arguments are missing, unknown arguments are specified, or argument values are of the wrong type or out of range.\n    - if the provided key exists but is not a hash."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> HSET mykey field1 \"hello\" field2 \"world\"\n(integer) 2\nredis> HEXPIREAT mykey 1715704971 FIELDS 2 field1 field2\n1) (integer) 1\n2) (integer) 1\nredis> HTTL mykey FIELDS 2 field1 field2\n1) (integer) 567\n2) (integer) 567",
      "section_id": "examples"
    }
  ]
}
