I have a group of nodes living in Neo4J with a label: Image.
These nodes have three properties. ID, imgPath and Time_taken.
I am writing a Javascript function in which the user can select dates in two textboxes (start/end date) and then on button click a PHP script runs with a neo4j request.
I read that neo4j doesn't support date format. My question is if there is a straightforward way to query nodes based on a "date property". Please note that the date is not the same with the timestamp of the node's creation.
Thanks
D.
I suggest you take a look at GraphAware TimeTree, which allows you to attach events (Images in your case) to an in-graph time index and query by time, time ranges, etc.
In the next release (which will be out soon after Neo4j 2.2 is out), you will be able to configure the tree to automatically attach Images to the tree without you as a programmer needing to do the attachment explicitly.
This is the workflow I followed after all:
1) I used the datePicker of JQuery to select dates.
2) I found all the dates between the start and the end date.
3) I played with the strings and created the query in a suitable form.
In the query I used the LIKE in order to find similarities related with this part of the date: day Month Year (e.g. 12 Feb 2015).
4) I send the request using CURL (and PHP).
5) Got the results in JSON format.
So to sum up what actually helped me to solve the problem was to find the dates (using javascript/jquery) between a start and an end date and then use the LIKE functionality.
I hope this helps someone. I will post the code when I find some time.
D.
Related
My apologies, but I am not well versed in json. We are currently using a single level json file for date information, one file per tour package. These are fetched via js then processed and inserted into the appropriate spots on the webpage. What we would like to do is combined all the tours date information, plus some additional details, into a single json file that once fetched is cached on the browser for a few hours. Basically ending up with a local flat file "database" with all tours for js to access.
Doing the single level json was fairly straight forward, but combining it into multiple levels is more daunting. I am wondering:
1) if there is a specific format for the data as outlined below?
2) how to use js to extract the data from that format?
Each tour is designated by a numerical id and has number of values. So should this first level be one or two levels (this is only the data concept, not json code):
tours -> tour_id, price1, price2, price3, duration, level, dates
tours -> tour_id -> price1, price2, price3, duration, level, dates
The dates value will have multiple dates each with several values:
dates -> date1, date2, date3, date4, etc
each date has -> trip_code, start_date, end_date, price, spaces
The basic functionality will be, when the page is loaded js will read the tour value from the page, then find the appropriate tour within the json file. The general values will be extracted by one function and simply inserted into the page as is using innerHTML. The date values will be used by a different function to build strings and then those strings likewise inserted into the page.
As I read through available info, I find some folks use only braces, some use braces & brackets, various suggestions for extraction, etc. I appreciate any help towards which format / extraction method would be preferable. And by preferrable, I mean whichever format / method puts the least workload on the browser. Having a slightly larger file size due to extra braces or brackets is fine if it reduces the js overhead and speeds up the finished page.
While it is probably of no consequence to the answer, the json file will be built by PHP and saved as a static file on the server.
You can make the multi-level object in the form
multiLevel = { [tour_id]: yourOriginal1LevelObject}
For retrieving the tour you can use
const tour = multiLevel[tour_id]
or using destructuring
const {tour_id: tour} = multiLevel
I've seen this post already, and it didn't quite shed much light on what is going on.
I have a mongo server, that stores information about classes, what times and days they meet and what not. I also have an express server, that interacts with and returns this data.
When I look at the data in Robo3T (a mongo data viewer), it is formatted - as it should be - like so:
2018-09-07 04:00:00.000Z
But when the data comes back to the server, it comes back like this: 2018-09-07T04:00:00.000Z
What is causing this? In no way do i make any attempt to format this data before I display it. I also checked the server output, which returns it the same way:
I guess my question is, why is this happening? and is this impacting my ability to query results from mongo based on a date range? Any assistance would be much appreciated, thank you.
Robo 3T just happens to display dates that way. This does not mean that it actually is stored that way. When you switch the view to "text mode", you will see that it actually is ISODate("2018-09-07T04:00:00.000Z") (with the T).
This format is actually the date format string that is used in JavaScript. And yes, the T is required. See What are valid Date Time Strings in JavaScript?
I'm using FormatJS library along with Handlebars to display a list of events that occured in the past. I'm calling for an endpoint on my server's REST API which returns me the list of events in Json, with datetimes to display for each event. ATM I'm saving datetimes in the DB using GMT time zone.
So when I'm getting my Json, I'm handling datetimes like this :
{{formatRelative commentDate}}
My issue is, since the datetimes are stocked in GMT, they display also like that. For example, since I'm on a GMT+2 timezone, as soon as a new event is created and shows up on the list, I see it "happened 2 hours ago" while it should be "a few seconds ago".
So, is there a way I can handle this ? Am I making a mistake in saving datetimes in GMT in my DB, and if so, how would you handle datetimes coming from different timezones and displaying them to people in other timezones ?
Of course I could customize the formatRelative helper to play with getTimezoneOffset and get the wanted result, but I wanted to know if there is something better to do.
Thanks a lot ahead !
The key to understanding your question is what you wrote in the comments:
Getting the Json, containing datetimes in the format 2016-02-28 10:15:53 - that's UTC time
You should ensure the value in JSON is in full ISO8601 format, including the appropriate offset or Z character to indicate UTC: 2016-02-28T10:15:53Z
Without the offset, most implementations will consider the value to be represented in local time, which explains your results.
Thus, the problem is with your server-side code, not your JavaScript code. There may be a client-side workaround you could apply when the date string is parsed from JSON, but really the best solution would be to qualify it at the server.
Is it possible to temporarily change the system date in NetSuite for purposes of testing date triggered scripts? If not is there a way to overload all NetSuite date functions so that a future or past date could be simulated for a given user in the sandbox?
We have email notifications that are sent based on the number of days before a certain NetSuite record expires. Rather than make the users wait for several days to go by to test this feature or change expiration date of records I want to provide a UI to allow the NetSuite system date to be changed.
I'd prefer the date override to be specific to the user and not for the entire sandbox instance so more than one user can simulate future/past dates. The date override would need to work in both client and server SuiteScript code as well as scheduled scripts.
A possible workaround is create two script parameters. A checkbox to indicate the script is in debug mode and a debug date where you can specify any date you want.
Then on your script, check if the checkbox is checked. If it is checked use the value in the date parameter for the comparison instead of the system date.
You can create a deployment parameter field {testDays}.
In production make it zero. In Test environment give it some negative numbers.
create something like the following
newTempDate = nlapiAddDays({expirydate}, {testDays})
and use the newTempDate for your criteria everywhere.
I'm not sure of the availability of such a functionality in Netsuite that allows you to customize the System Date. As far as I'm concerned, your schedule scripts will always pick timestamp of the server instance. No matter if you change your date / timezone, all your transactions, records, scripts & login times will display Pacific time, where the server computer is located.One solution could be defining your own Date in your script instead changing the server date (In case you don't want to change the date in your record) and validate your records against it.
I want to run a scheduled job every 10 minutes which will do the following:
Check the table records and delete those who hasn't been updated for 10 minutes.
How is it possible to get the current server date in javascript in order to compare it?
Use the JavaScript Date object. Just creating a new Date object without parameters will give you the server date and time. It will of course be in GMT as all the servers in Azure run on GMT. However, be aware of clock drift. Each of the servers could be slightly off from one another time wise, so it may not be exact if comparing times across servers.
var cutOfDate = new Date();
You could also load up one of the JavaScript data libraries like Moment or something like that as well if you need to do a lot of date formatting or evaluations.
Another option is to simply have a stored procedure that is called to perform your clean up for you. The stored procedure could then use the SQL GETDATE() to determine the current date and do the deletes based on that.
I think what you want is this. Giving you an overview:
http://azure.microsoft.com/en-us/documentation/articles/mobile-services-how-to-use-server-scripts/#access-tables
For date and time
http://azureinmycloud.net/2011/10/26/working-with-datetime-now-in-windows-azure-apps/