Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-21-2020 11:07 PM
For a scheduling app, I am receiving a time stamp as something similar to a localdatetime
. Specifically, it’s generated by an HTML datetime-local
input, as YYYY-MM-DDTHH:MM
, and that works just fine when passed to localdatetime
.
The node representing the appointment location has a timezone
property, so I was thinking of building a localdatetime
and then attaching the time zone after that, but I can’t figure out how to convert a localdatetime
to a datetime
by bolting on a given timezone. datetime(localdatetime($timestamp))
adds a time zone, but sets it to UTC and that’s not quite what I want. I want to be able to provide that time zone.
An alternative I thought of was to break down the localdatetime
into component parts and rebuild the datetime
from that, but apoc.date.fields
doesn’t return datetime
-compatible map keys. What I’m looking for is something like this:
MATCH (office:Office { id: $office_id })
CREATE (appt:Appointment {
timestamp: datetime(
localdatetime($appointment_time),
{ timezone: office.timezone }
)
})
Obviously this doesn’t work since datetime
only takes a single argument but is there a way to do something like this?
Solved! Go to Solution.
05-22-2020 12:24 PM
You may want to review the temporal types documentation, there are sections for creating values based upon other temporal type values, check out the examples:
05-22-2020 11:03 AM
Hi @jgaskins,,
You can change localdatetime to string and the use datetime eg.
''' return datetime(tostring(localdatetime('2020-05-21T21:02'))+'z') '''
05-22-2020 12:24 PM
You may want to review the temporal types documentation, there are sections for creating values based upon other temporal type values, check out the examples:
05-22-2020 10:16 PM
TIL datetime()
accepts a datetime:
key. For some reason I thought you could only pass another temporal type as the parameter and it would restructure it into the map. Thanks @andrew.bowman, this is precisely what I was looking for:
datetime({
datetime: localdatetime('2020-05-23T18:30'),
timezone: 'America/New_York'
})
# => "2020-05-23T18:30:00[America/New_York]"
All the sessions of the conference are now available online