I need to get nodes and relationships based on start date and end date...
For example: a 'Company' has employees ('Person' nodes).
There are some relationships for each company ('CEO', 'ProductManager', 'Engineer'... and they all have "startDate" and "endDate" (of the role).
Now i want to see the network as it was in the year 2020.
My question is: When i import data from CSV, should i set the date attributes as date or as string and then convert it to date in the query?
What is the correct query for each one of the options?
Thanks,
If you want to perform queries on a date, then store the property as a date so you can index the property and leverage the index.
As a note, dates in YYYY-MM-DD format are in both alphanumeric and chronological order, so you can store them as strings in this format and be able to compare the strings as you would the dates. Just an option.
ββββββββββββββ€ββββββββββββββββ€ββββββββββ€βββββββββββ
βn.p1 βdate(n.p1).yearβn.p1.yearβn.p1.monthβ
ββββββββββββββͺββββββββββββββββͺββββββββββͺβββββββββββ‘
β"2024-04-02"β2024 β2024 β4 β
ββββββββββββββ΄ββββββββββββββββ΄ββββββββββ΄βββββββββββ
note the 2nd `return` i.e. date(n.p1).year is converting the n.p1 property to a `date` format/datatype though it should be noted it was inserted as a date format/datatype so is a bit unecessary.