# HINCRBY

> Add an integer to the value of a hash field.

URL: https://docs.hotkv.com/commands/hincrby/

```
HINCRBY key field increment
```

- Group: Hash
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`HINCRBY` adds `increment` to the integer stored in `field` of the hash at
`key` and returns the new value. A missing key or field starts at `0`. Use a
negative `increment` to subtract. The field keeps any time to live it already
had.

The increment and the stored value must both be signed 64-bit integers written
in plain decimal form.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Integer: the value after the increment | Same |

Errors:

- `ERR value is not an integer or out of range` if `increment` is not an
  integer.
- `WRONGTYPE` if `key` holds a value that is not a hash.
- `ERR hash value is not an integer` if the field holds something that is not
  an integer.
- `ERR increment or decrement would overflow` if the result does not fit in a
  signed 64-bit integer.

## Examples

```
127.0.0.1:6379> HSET stats:page views 10
(integer) 1
127.0.0.1:6379> HINCRBY stats:page views 5
(integer) 15
127.0.0.1:6379> HINCRBY stats:page views -20
(integer) -5
127.0.0.1:6379> HINCRBY stats:page clicks 1
(integer) 1
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[HINCRBYFLOAT](https://docs.hotkv.com/commands/hincrbyfloat/index.md), [HSET](https://docs.hotkv.com/commands/hset/index.md), [HGET](https://docs.hotkv.com/commands/hget/index.md),
[INCRBY](https://docs.hotkv.com/commands/incrby/index.md)