Support for date range queries - alasql

I've big json array which contains date in one of the field in the ISO date format. Is it possible that I can fire up date range ( between two dates). Also does it support in SQL cluase ? Can you please provide a working example ?

Related

How to i change the date time format on Google Sheets?

I am working on a datasheet on Google sheets and I am trying to change values in column (D) to date time format, so I went to Format<number<date time. But only a few values are getting converted and the rest remain the same. Please see below-
Screenshot of column D
The values aligned on right are converted and the left ones aren't. I even tried paint format, trim white spaces but it didnt work. Please suggest a way on how to resolve this error. Also, there are 49623 values in column D.
thank you
Your spreadsheet is set to a locale that uses the mm/dd/yyyy date format, while your data is using the dd/mm/yyyy date format. That means that the dates where the day of the month is less than or equal to 12 will get converted to dates incorrectly, and the rest of the data will remain as text strings.
To make it work, choose File > Settings > Locale and choose a locale that matches your data, then repaste the data to convert it correctly.
The "49623 values" are dateserials that can be converted to dates by formatting them in a date format. See this answer for an explanation of how date and time values work in spreadsheets.

Creating a base date for analysis in tableau

I have a problem where i want to set a base date to a date time variable in the database. I would then use the base date for my aggregations. And the days subsequent to this base date would be categorised as Day1, Day2 and so on.
So for example, if I want to see cohorts of orders created by the base date - I would want the calculated after this date. I don't want to do this using a date filter.
Image below:
It seems like you could use the DATE function to convert your field, like this:
DATE([Acquisition Date])
If you don't already have the year value stored, but have a method in mind to add it, you could use MONTH([Acquisition Date]) to obtain the month and date and DAY([Acquisition Date]) to obtain the date. You could then use MAKEDATE function to build the date or MAKEDATETIME function to build the datetime value.
Once it's stored as a date value, you could use DATEADD to add and subtract days to it as needed.
There are multiple formulas available for converting Tableau dates, described here: https://help.tableau.com/current/pro/desktop/en-us/functions_functions_date.htm
Is this what you're looking for?

Neo4j, How can I compare dates that stored as strings?

I have a date in my Neo4j database that is 9-03-2021 and this date is stored as a string in Neo4j, how would I compare that this date for example is <= 9-05-2021 ?
I am basically trying to return all nodes in my database where the date field is <= a certain date, or >= a certain date, where these dates are stored as strings,
thank you
The better way, of course, is to store the date as a temporal property, index it, and then in your predicates on the property compare it to other temporal values.
If you're stuck with a String property, then it would be best to use strings that afford comparison in YYYY-MM-DD format, as the string comparisons in that format will match temporal comparisons.
Your current format, DD-MM-YYYY, does not afford comparisons to other strings in that format. If you are stuck with this current format for your properties, then as Tomaž said in the comments, you would need to parse this into a type that is comparable (such as by using apoc.date.parse() ) which should give you a unix epoch timestamp (long value), and you would similarly need to parse the dates that you are comparing it to so they are all of the same type.
The problem with that approach is that you cannot use indexes here, so you won't be able to speed up the lookup. So you really should consider either using temporal properties, or at least using strings in a comparable YYYY-MM-DD format.
I would compare them both as strings:
WHERE
9-03-2021 <= '9-05-2021'
I found it helpful to use Neo4j's date() function to convert a date stored as a string into a temporal value if you want to compare a string value to a temporal value. First I trim the string so it's formatted as YYYY-MM-DD and then I place it inside the date() function.
For example start_date in the below example stores the start date and time as a string but I only want to return values where the start date is less than today's date:
WHERE
date(left(start_date, 10)) < date()

Warning about "xsd:date"

I am using Jena to parse a "TTL" formatted file. I see the warning in the console
Lexical form '1896-13-04' not valid for datatype http://www.w3.org/2001/XMLSchema#date
I want to know why this warning happens.
Per the XML schema specification for xsd:date:
The ·lexical space· of date consists of finite-length sequences of characters of the form: '-'? yyyy '-' mm '-' dd zzzzzz? where the date and optional timezone are represented exactly the same way as they are for dateTime
i.e. dates must follow the International Convention of having year then month then day.
From the example given your data appears to have dates in the American convention which has year then day then month. Since 13 is not a valid month you receive a warning.
Your input data is not valid according to the specifications and therefore may not be processed correctly when you try to ask queries based upon that data e.g. Find items with dates before or after a specific date of interest. Dates for which you are not receiving a warning maybe interpreted incorrectly a day and month being interchanged.
You need to correct the data as otherwise this will cause you issues later. If the data is from a public data source you should let them know that they have a data quality issue, if the data is being created by yourself you need to correct your data generation so the dates following the specification.

change date format in sqlite

Change this date format which is in sqlite db 12/10/11 to 12-10-11 (mm-dd-yy) I am unable to do so .I am a noob in sqlite and have to parse this value SELECT strftime('%d-%m-%Y',Date) from report but I am getting null as sqlite db excepts value in mm-dd-yy so How do I convert format 12/10/11 to 12-10-11 (mm-dd-yy) .Thanks in advance .Really appreciate the help.
The short answer:
If you have a text string stored as "12/10/11" that you want reported as "12-10-11", you should use the replace(X,Y,Z) function, to replace occurrences of Y in X with Z. Thus:
SELECT replace('12/24/11','/','-');
will return:
12-10-11
The long answer:
First, dates do not actually exist as a proper datatype in SQLite. They're stored as either TEXT, REAL, or INTEGER values. See date and time datatype in SQLite. So it depends upon how your date was stored in the database.
Second, you seem to be implying that you stored the date in a "mm/dd/yy" format. That's not a valid/useful TEXT format to be storing date/time values (as the date cannot be sorted, cannot used in "greater than" and "less than" operations, cannot be used in SQLite date functions, etc.). You really want to store datetime values in one of the formats listed in the "Time strings" section of the date and time functions document.
So, generally you should store your date/time values in one of those formats, use NSDateFormatter to convert that to a NSDate when you retrieve it from the database. And when you want to display the date value in your app, use whatever format you want for output.
But, if you don't care that the dates are stored as text strings and are not effectively usable as dates in SQLite, then just treat it as a plain old TEXT string and use TEXT functions, such as replace(X,Y,Z) to replace occurrences of "/" with "-", as outlined above.

Resources