Search for records updated on specific date and time - jql

I am trying to pull tickets that were updated on a certain date at a certain time. Specifically, i am looking for tickets that were updated on 8/17 between 3:15 pm ET and 3:20 pm ET.

From the documentation, you may try using a range:
project = some_project AND
updated >= "2018/08/17 15:15" AND updated <= "2018/08/17 15:20"
Replace some_project with the actual name of your project. If you are not performing this search from the ET timezone, then you'll need to shift the above timestamps.

Related

Split date_start and date_end by hours on Metabase

I have table with a column "Begin At" and another column "End At" that represent when a task begin and when a task end i would want to have a Bar display which display the cuantity of tasks that are being done in a specific hour along an interval of time.
For example, from the following table
I would want to be able to see that from 07/12/2021 21:00 to 07/12/2021 22:00 there were 3 tasks being done (row 1, row 2, row 3).
And also as i will have several thousands of rows i would want to use the date widget from metabase in order to specify range of times.
I have been struggling with this from the last week, i tried to create auxiliar questions where to query after but finally my only succeed was to hard code the 24 hours from a day but then i was not able to use the time widget and i needed to specify the dates myself on the sql each time i want to check a specific day and also i only was able to check from 24 to 24 hours, not from for example 02/12/2021 6:00 to 04/12/2021 18:00
My metabase is running on a PostgreSQL database. Is this even possible on Metabase? If not what are your advices to build this? Other plaforms? Pure SQL? Python?
Thank you so much
I am not sure about metabase but from a PostgreSQL point of view this calls for the use of range-types, specifically the tsrange/tstzrange, depending on whether you have time zone information or not.
So a query could be:
SELECT
*
FROM "someTable"
WHERE
tsrange("Begin At", "End At", '[)')
&&
tsrange('02/12/2021 6:00', '04/12/2021 18:00', '[)')
However I don't know how you would get the '02/12/2021 6:00' and '04/12/2021 18:00' out of your metabase user-interface.

How to merge data in SQL

I run a query every day to place in a file. It is regarding effective date and term dates of coverage. occasionally have a group that will actually term and become effective again the next day. I need help with SQL code that will pick up the original effective date and the latest expiration date. The example that I am giving is a very small part of the table.. due to hippa regulations. The SQL code that I currently am using is super easy query code and I have supplied just the lines of data within the attachment.you will see where this member has 2 effect dates and 2 term dates I need to display it as one..with 01/01/2018 as effect and 12/31/9999 as term. cannot figure out how to add an attachment.. so I am just going to copy the two rows.
meme_altid meme_eff meme_trm
S409666X1E 2018-01-01 2018-12-31
S409666X1E 2019-01-01 9999-12-31
Earliest eff and latest term?
Select meme_altid, Min(meme_eff) As eff, Max(meme_trm) As term From #tbl
Group By meme_altid

SQL set date_out automatically if today ends

I have a visitor system. when the visitor checks in, it sets a date_in. and when the visitor checks out it sets a date_out.
but if a visitor forget to check out. it says he has no date_out so I try to figure out how to set the date_out if the visitor didn't check out.
an example:
Check in: 2015-01-19 12:00:00
visitor forget to check out that day.
so if date is: 2015-01-19 23:59:59. I want it to set it automatically on the date_out.
because with another query I ask all the visitor without a date_out to show. so I can see who is in the building that day.
is there any way to do this automatically?
Table structure
date_in is set when the visitor checks in with his name.
My suggestion - rather than editing the data (and subsequently not being able to identify genuine check-outs at 23:59), just update the query:
SELECT * /* TODO - actual columns */
FROM visits
WHERE
date_out IS NULL AND
date_in >= DATEADD(day,DATEDIFF(day,0,CURRENT_TIMESTAMP),0)
Where the expression DATEADD(day,DATEDIFF(day,0,CURRENT_TIMESTAMP),0) is just a way of saying "midnight at the start of today".
The above query should give you the same results as what you're asking for, but leave the actual recorded data intact. That is, only people who've entered today but not left are reported.
The reason I'd recommend not changing the recorded data is in case you decide to change the rules later - i.e. using a different interval than one day to consider a visitor to have left.
You could create a job that runs 23:59:59 every day that fills the date_out with data.
Assuming you have the data in a single row, you can just update the values periodically:
update visitors
set check_out = cast(convert(varchar(10), date_in, 121) + ' 23:59:59') as datetime)
where check_out is null;
This can be done at your leisure, rather than guaranteeing that some job run at a specific time.

displaying records with a date at least one day greater then or = to today

I have a field in a table called DATEF. It displays dates as follows: 2013-11-25 08:30:00.000. The field is used to show appointment dates. What I need to show are future appointment dates from today or = to today. (Getdate) for some reason this is not working for me today. Appreciate the help. Thank you.
Try this... you're probably failing to factor in the time component. (This is for SQL Server, you'll have to find the equivalent for your respective environment)
SELECT <SOMETHING>
FROM TABLE
WHERE DATEF >= CONVERT(DATE,GETDATE())

Date range handling logic in Access

I've got a bit of a weird logic problem that I can't seem to wrap my head around (perhaps from studying it for too long).
Where I work we have a very old piece of software that we're required to use to track the status of equipment that we use. This software provides very little functionality to manipulate these statuses to try and provide a good analysis of downtime. I've been working on a database application in Access (since it's the only tool they make available to me) to import status data from the old system into a format that is more easily manipulated.
The way status data is spit out from the old program is fairly straight-forward:
EQUIPNAME STATUS STARTDATETIME ENDDATETIME
It's easy enough to read that text and insert it into the table in Access. The problem I'm having comes from trying to find how many hours a piece of equipment spent in different statuses over different date ranges.
The start/end date/time can be any length of time. Finding which rows contain the dates is difficult. I've been using BETWEEN statements in SQL to try and find them which, for the most part, works out well:
SELECT * FROM Statuses WHERE
(StartDateTime BETWEEN [StartDT] AND [EndDT])
OR
(EndDateTime BETWEEN [StartDT] AND [EndDT])
The real issue is when StartDateTime is BEFORE StartDT and EndDateTime is AFTER EndDT (ie the entire range I'm looking for is INSIDE this status's start/end dates). It simply doesn't find it, which makes sense.
I can't seem to come up with an elegant solution to this. I need to be able to select all rows which contain a status that contains or is contained within the supplied date range. I wouldn't normally come here for such a simple problem, but my brain and Google-fu are failing me.
A little bit of sample data:
EQUIP STATUS STARTDATETIME ENDDATETIME
A123 OPER 01/30/2013 21:30 12/31/1999 00:00
A123 DFM 01/26/2013 10:42 01/30/2013 21:29
A123 OPER 01/01/2013 00:00 01/26/2013 10:41
B123 OPER 01/01/2013 00:00 12/31/1999 00:00
C123 DFU 01/29/2013 12:31 12/31/1999 00:00
C123 OPER 01/01/2013 00:00 01/29/2013 12:30
Any kind of booking collusion occurs when:
RequestStartDate <= EndDate
and
RequestEndDate >= StartDate
The above will ALSO return overlaps. So if I query today + tomorrow, and a range starts at the being of the year to the end of the year, the query WILL be included in the range.
Eg:
Select * from tblEQUIP
where
#01/31/2013# <= ENDDATETIME
and
#02/01/2013# >= StartDateTime
At that point you can "process" each record. You likely have to use something like:
Do while RecordDate.eof = false
For datePtr = RequestStartDateTime to RequestendDateTime
If datePtr >= RecordData!StartDateTime and DatePtr <= RecordData!EndDateTime then
DaysTotal = DaysTotal + 1
End if
Next DatePtr
recordData.Movenext
loop
The above is air code, but shows the basic processing loop you need to first grab the overlapping records, and then a processing loop to add up days/time for each record in your date range that does fall withing the given date range.
Interesting question ! Sorry not to have much time now to eleborate, but I would advise to explore the Partition function for that, or and/or doing a crosstab query with the date as column heading. More on msoffice site and here.