# Date Nodes (YYYY-MM) Usage?

**URL:** <https://community.neo4j.com/t/date-nodes-yyyy-mm-usage/46967>\
**Category:** Cypher\
**Tags:** performance, cypher\
**Created:** [November 4, 2021, 5:09pm UTC](https://community.neo4j.com/t/date-nodes-yyyy-mm-usage/46967 "2021-11-04T17:09:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbandor](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mbandor/32/6828_2.png) [@mbandor](https://community.neo4j.com/u/mbandor)\
**Post date:** [November 4, 2021, 5:09pm UTC](https://community.neo4j.com/t/date-nodes-yyyy-mm-usage/46967/1 "2021-11-04T17:09:30Z")

</div>

After having attended the Graph Modeling class, I'm looking to optimize a graph I'm using that tracks product expiration dates. Originally I had the expiration date as a property of the product, but in reviewing the materials from the Graph Modeling class, it seems to make sense to create an Expiration Date node. not only for performance reasons, but also to show additional clusters of products expiring. I can obviously create an Expiration Date node with a year value, but I'm looking at a year and month (YYYY-MM). Does this make sense?

Secondly, I'm having issues extracting just the year and month from the existing date field (actual date) to use for the new Expiration Date node. Any suggestions on approaches for just this format?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mbandor](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mbandor/32/6828_2.png) [@mbandor](https://community.neo4j.com/u/mbandor)\
**Post date:** [November 4, 2021, 6:45pm UTC](https://community.neo4j.com/t/date-nodes-yyyy-mm-usage/46967/2 "2021-11-04T18:45:02Z")

</div>

I found a partial solution by using a ".year" on the end of my date property to just return the year. Is there a way to make it year and month? The source property is a date type (YYYY-MM-DD).

---

<div class="post-metadata">

**Author:** ![mbandor](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mbandor/32/6828_2.png) [@mbandor](https://community.neo4j.com/u/mbandor)\
**Post date:** [November 4, 2021, 8:09pm UTC](https://community.neo4j.com/t/date-nodes-yyyy-mm-usage/46967/3 "2021-11-04T20:09:18Z")

</div>

I found a way to do this through a toString conversion. it gets me what I needed.

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [November 4, 2021, 8:26pm UTC](https://community.neo4j.com/t/date-nodes-yyyy-mm-usage/46967/4 "2021-11-04T20:26:45Z")

</div>

@mbandor

or what about

```auto
 return date(date()).year + '' + date(date()).month;
+---------------------------------------------+
| date(date()).year + '' + date(date()).month |
+---------------------------------------------+
| "202111" |
+---------------------------------------------+

```

---

<div class="post-metadata">

**Author:** ![mbandor](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mbandor/32/6828_2.png) [@mbandor](https://community.neo4j.com/u/mbandor)\
**Post date:** [November 4, 2021, 8:41pm UTC](https://community.neo4j.com/t/date-nodes-yyyy-mm-usage/46967/5 "2021-11-04T20:41:23Z")

</div>

I'm pulling the date from the product node (actual date, not a string representation) and then creating a new date node with just the year and month. The solution I had wasn't elegant but it worked for what I needed. I can now see all the products related to a date node. It traverses quicker than just using a date property in the Product node and pattern (things expiring in the same time frame) now shows up with the relationship.

This is the script I used:

> MATCH (p:PRODUCT)  
> MERGE (eos:EOS\_DATE {EOS\_Date: toString(p.EOS\_Date.year) + '-' + toString(p.EOS\_Date.month)})  
> MERGE (p)-[:END\_OF\_SUPPORT]-\>(eos)  
> RETURN eos, p
