# How to store/retrieve date in Aerospike database?

**URL:** <https://discuss.aerospike.com/t/how-to-store-retrieve-date-in-aerospike-database/1295>\
**Category:** How Aerospike Works\
**Created:** [May 19, 2015, 2:14pm UTC](https://discuss.aerospike.com/t/how-to-store-retrieve-date-in-aerospike-database/1295 "2015-05-19T14:14:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mangesh](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mangesh](https://discuss.aerospike.com/u/mangesh)\
**Post date:** [May 19, 2015, 2:14pm UTC](https://discuss.aerospike.com/t/how-to-store-retrieve-date-in-aerospike-database/1295/1 "2015-05-19T14:14:00Z")

</div>

How to store date in Aerospike database and retrieve data based on this date.

Consider query like **Select \* From Users Where StartDate \< now()**, how to retrieve data like this in Aerospike database??

---

<div class="post-metadata">

**Author:** ![manigandham](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/manigandham/32/58_2.png) [@manigandham](https://discuss.aerospike.com/u/manigandham)\
**Post date:** [May 19, 2015, 11:30pm UTC](https://discuss.aerospike.com/t/how-to-store-retrieve-date-in-aerospike-database/1295/2 "2015-05-19T23:30:25Z")

</div>

1. Use a bin to hold the DateTime value as an integer
2. Create a numeric secondary index on this bin
3. Use a query with range filter to get the records back.

You can use the Unix/epoch time standard = **number of seconds since January 1, 1970**

> **[Unix time](https://en.wikipedia.org/wiki/Unix_time)**
>
> In computing, Unix time (also known as Epoch time, Posix time, seconds since the Epoch, Unix timestamp or UNIX Epoch time) is a system for describing a point in time. It is the number of seconds that have elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00 UTC on 1 January 1970.
> Unix time is not a true representation of UTC, because a leap second and the second before it have the same Unix time (or after it, implementation dependent). Put differently, every day in Un...

---

<div class="post-metadata">

**Author:** ![mangesh](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mangesh](https://discuss.aerospike.com/u/mangesh)\
**Post date:** [May 20, 2015, 12:19pm UTC](https://discuss.aerospike.com/t/how-to-store-retrieve-date-in-aerospike-database/1295/3 "2015-05-20T12:19:28Z")

</div>

Thanks for quick response.
