I am working in neo4j database.
i have csv file column is ENTRY_DATE format is "08-apr-15" String type date.and current date format is "21-10-2016".How to change the String type Entry_date is like current date format.but my need is compare the current date with entry_date column then calculate the difference of month between two dates.
You can parse both strings using Cypher's string functions.
WITH {current_date} AS current_date
WITH split(current_date, '-') AS month_tuple
WITH month_tuple[1] AS c_month, month_tuple[2] AS c_year
WITH {jan: 1, feb: 2, ... dec: 12} AS month_map, c_month, c_year
LOAD CSV WITH HEADERS FROM "place" AS row
WITH row, row.ENTRY_DATE as e_date, c_month, c_year, month_map
WITH row, c_month, c_year, split(e_date, '-') AS e_tuple, month_map
WITH row, c_month, c_year, e_tuple[2] AS e_year, e_tuple[1] AS e_month_key, month_map
WITH row, (toInt(e_year) -toInt(c_year)) * 12 as year_diff, month_map[e_month_key] - toInt(c_month) AS month_diff
WITH row, year_diff + month_diff AS months_later
But InverseFalcon is definitely right in that this would be way better if handled through the backend. Clean up your CSV before import and pass in a better source of current date and you can cut most of that query out.
Neo4j doesn't have much support for date/time operations at all. If your backend framework/language has good date/time support, I'd recommend doing that calculation there instead of from the db itself.
But if you are looking for a pure neo4j solution, the APOC Procedures library has some conversion and formatting support, but if that's not enough, you may want to look at GraphAware's neo4j timetree. That should give you some graph operations for finding the years or months between different dates.
Related
So I have a formula one one sheet that calculates the difference between the current date (Using the today function) that corresponds to when a repair was requested - this column gives me how many days have passed since the request was made. In a separate sheet, I want to query the requests that are beyond 14 days old but less than 22 days. I write the query as:
Select A,B,C,D,G Where J>14 and J<22
but the cell just displays "N/A". But if I rewrite the code with single quotes on the 14 and 22 as:
Select A,B,C,D,G Where J>'14' and J<'22'
It returns repair requests that are two days old. This tells me that it recognizes the formula results as Strings even if I already set the format to Number.
Can anyone help?
To anyone wondering, I was able to fix this issue by using the VALUE() function (which works for both Google Sheets and MS Excel) which converts any string to numbers.
if J column are dates try:
=INDEX(QUERY({A:G, DAY(J:J)}
"select Col1,Col2,Col3,Col4,Col7
where Col8 > 14
and Col8 < 22")
The data on the page is delivered as follows:
https://int.soccerway.com/international/europe/uefa-champions-league/20192020/group-stage/r54142/
1 - Below each schedule is a link to the match.
2 - I would like to import all data at once.
3 - The result I seek would be as follows:
4 - Import separately, I can, but as they are separate formulas, it takes a long time, I would like a way to import all at once, for a formula only if it were possible.
5 - The Xpath are:
"//*[#class='date no-repetition']"
"//*[#class='score-time status']/a"
"//*[#class='score-time status']/a/#href"
6 - An important detail, I indicated the 'score-time status' because there are games that appear as 'score-time score' but these cannot be imported.
7 - There is another detail that complicates, the time comes with spaces between the sign of :, so for him I use the =SUBSTITUTE(," ","")
Is there any way to do this that I want?
I've tried using ={;;} to import the data, but can't make calls to more than two =IMPORTXML().
I also tried for =IMPORTHML() but it can't fetch the links from each of the below-hours matches and the date also appears in only one of the games...
How about this answer? I think that there are several answers for your situation. So please think of this as just one of several possible answers.
xpath:
Unfortunately, I couldn't find the xpath for directly retrieving the 3 values in your question. So in this answer, the following xpath are used.
Date: //td[#class='date no-repetition']/span
Time: //td[#class='score-time status']/a/span
URL: //td[#class='score-time status']/a/#href
Sample formula:
=ARRAYFORMULA({IMPORTXML(A1,"//td[#class='date no-repetition']/span"),IMPORTXML(A1,"//td[#class='score-time status']/a/span"),"https://"&IMPORTXML(A1,"//td[#class='score-time status']/a/#href")})
In this formula, the URL of https://int.soccerway.com/international/europe/uefa-champions-league/20192020/group-stage/r54142/ is put to the cell "A1".
Retrieved 3 values are put to the column "A", "B" and "C".
Result:
Note:
In above case, I think that the time zone might be the place when the values are retrieved by IMPORTXML.
If you want to change the timezone to your own Spreadsheet, how about the following sample formula?
=ARRAYFORMULA({IMPORTXML(A1,"//td[#class='date no-repetition']/span/#data-value")/86400+DATE(1970,1,1),IMPORTXML(A1,"//td[#class='date no-repetition']/span/#data-value")/86400+DATE(1970,1,1),"https://"&IMPORTXML(A1,"//td[#class='score-time status']/a/#href")})
In this case, please set the format to the column "A" and "B".
In above formula, the date and time is retrieved the unix time. This value is converted to the serial number. So the converted value can be used as the date and time at Spreadsheet.
References:
IMPORTXML
ARRAYFORMULA
If this was not the direction you want, I apologize.
I'm working with two columns,
column A: a list of timestamps
column B: a list of numbers
I'm trying to use the sumif(range, criteria, [sum range]) function to check if the month in column A is January, and so on for all months.
The issue is that I need a way to either convert the range for the sumif to month names, or use criteria other than a string (because a timestamp isn't going to ever be "=January".
My thought was that I could do either
=sumif(TEXT(TO_DATE(A2:A),"mmmm"), "=January", B2:B)
or
=sumif(A2:A, TEXT(TO_DATE(A2:A),"mmmm")="January", B2:B)
these are more or less pseudo-code, I'm trying to convey my thought process
I understand I could create a new column that converts the timestamps into months, but is there anyway I can preform this sumif, without having to make a new column?
Using SUMIFS, with dates you set the extents, this works in excel and google sheets:
=SUMIFS(B:B,A:A,">=" & DATE(2019,1,1),A:A,"<" & DATE(2019,2,1))
With Google Sheets you can also use filter:
=SUM(FILTER(B:B,MONTH(A:A)=1))
"=2" = February, "=3" = March, etc.
=ARRAYFORMULA(SUMIF(MONTH(A2:A), "=2", B2:B))
if you want to select it from a drop-down menu use:
=ARRAYFORMULA(SUMIF(MONTH(A2:A), "="&MONTH(F2&1), B2:B))
I have a large database (almost 450,000 cells from A to AC columns and 15,000 rows), so I need that instead of importing all the data I just need that data from an specific month or weeknums.
Right now I'm doing it manually but it takes a lot of mi time to manually change the ranges of my IMPORTRANGE. I have a formula like:
=QUERY(IMPORTRANGE("10oV2kyv3aclctdydhZwxG3Y8VLdfkAr28aLz5fVZL1o","Form Responses 1!A2:AC"),"Select * Where year(Col1)=2017 and month(Col1)=1")
But it tells me that the result is too long...
Instead of using one open-ended range use several import range and arrays, something like:
=QUERY(
{
IMPORTRANGE("10oV2kyv3aclctdydhZwxG3Y8VLdfkAr28aLz5fVZL1o","Form Responses 1!A2:AC5001");
IMPORTRANGE("10oV2kyv3aclctdydhZwxG3Y8VLdfkAr28aLz5fVZL1o","Form Responses 1!A5002:AC10001");
IMPORTRANGE("10oV2kyv3aclctdydhZwxG3Y8VLdfkAr28aLz5fVZL1o","Form Responses 1!A210002:AC15001")
},
"Select * Where year(Col1)=2017 and month(Col1)=1"
)
Goal: Return a specific value from a table of data based on a query (kinda like if VLOOKUP provided the option for multiple criteria).
Problem: The data in the source table is a value and I can't change the data source's format. When I run my QUERY function I get #N/A. I know it's due to the data type of the source table data because when I update the format to "plain text" the value works.
Here is my Query:
=QUERY(SessionsData,"select D where B='"&TEXT(Date(YEAR(TODAY()),4,$A143),"yyyy-MM-dd")&"' limit 1",0)
I know the logic works, watch this video for a brief demo.
How can I get this comparison to return results?
Adapted from this answer:
The Query language has two functions to help with date comparisons.
The todate() scalar function will convert spreadsheet dates (like your column B) to query date values. If the value started as a datetime, it returns just the date portion.
The date modifier treats specifically formatted strings as query date values.
Use them like so:
=QUERY(SessionsData,"select D where todate(B)=date '"&TEXT(Date(YEAR(TODAY()),4,$A143),"yyyy-MM-dd")&"' limit 1",0)
^^^^^^^^^ ^^^^