# Generate timestamp from date

**URL:** <https://community.neo4j.com/t/generate-timestamp-from-date/8555>\
**Category:** Neo4j Graph Platform\
**Tags:** cypher\
**Created:** [July 4, 2019, 7:38pm UTC](https://community.neo4j.com/t/generate-timestamp-from-date/8555 "2019-07-04T19:38:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ri8ika](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ri8ika/32/4181_2.png) [@ri8ika](https://community.neo4j.com/u/ri8ika)\
**Post date:** [July 4, 2019, 7:38pm UTC](https://community.neo4j.com/t/generate-timestamp-from-date/8555/1 "2019-07-04T19:38:16Z")

</div>

I couldn't see any argument in timestamp function. But can we create timestamp from date supplied?

I could also generate timestamp from other language like python or javascript. But it differs to the timestamp as in cypher query language. So, what's the best way to generate timestamp value from given date?

---

<div class="post-metadata">

**Author:** ![mike\_r\_black](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mike_r_black/32/30089_2.png) [@mike\_r\_black](https://community.neo4j.com/u/mike_r_black)\
**Post date:** [July 4, 2019, 9:40pm UTC](https://community.neo4j.com/t/generate-timestamp-from-date/8555/2 "2019-07-04T21:40:00Z")

</div>

What data do you have to work with? Is it `strings`/`ints` or is it already a date and you're trying to go to `datatime`? An example with what you have would be helpful.

```auto
RETURN datetime('2015-06-24T12:50:35.556+0100') AS theDateTime

```

Otherwise I'd just refer you to the manual on [temporal date types](https://neo4j.com/docs/cypher-manual/current/syntax/temporal/)

---

<div class="post-metadata">

**Author:** ![ri8ika](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ri8ika/32/4181_2.png) [@ri8ika](https://community.neo4j.com/u/ri8ika)\
**Post date:** [July 4, 2019, 10:34pm UTC](https://community.neo4j.com/t/generate-timestamp-from-date/8555/3 "2019-07-04T22:34:47Z")

</div>

Ah, I don't want to get datetime. But, I want to store date as timestamp in neo4j.

I would be happy if there was something like:

```auto
timestamp('2017-2-9') // but there's no arg in timestamp function

```

---

<div class="post-metadata">

**Author:** ![mike\_r\_black](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mike_r_black/32/30089_2.png) [@mike\_r\_black](https://community.neo4j.com/u/mike_r_black)\
**Post date:** [July 4, 2019, 10:51pm UTC](https://community.neo4j.com/t/generate-timestamp-from-date/8555/4 "2019-07-04T22:51:43Z")

</div>

And you don't want to use?

```auto
RETURN date('2015-01-14') AS theDate

```

`datetime` is a timestamp, just by a different name. Here's the chart from the documentation showing what each data type supports

 ![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/d/d085d6070325c617834166d5ab0526b3cfbbfc98.png)

All you need to do is decide which one you need. If you only have the components of a date but are determined to have the time components included, you can do string concatenation to fill in zeros for the missing time values.

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [July 5, 2019, 2:14am UTC](https://community.neo4j.com/t/generate-timestamp-from-date/8555/5 "2019-07-05T02:14:40Z")

</div>

For getting the timestamp from datetime:

RETURN apoc.date.format(apoc.date.parse("2019-01-25 14:49:58", 'ms', 'yyyy-MM-dd HH:mm:ss'), 'ms', 'HH:mm:ss')

Result: "14:49:58"

If you have just date then timestamp: "00:00:00".

Another simpler approach:  
RETURN right("2019-01-25 14:49:58", 8);

Result: "14:49:58"
