I am trying to Remove data from One month (July) but I can't manage to write properly the SQL query in the console.
I have tried the following code and worked fine. I just need to find to way to write the range of one complete month (July).
DELETE
FROM Sandbox.SandboxTable
where Date = '2018-12-09T00:00:00'
I have tried different possibilities but had syntax errors. I will strongly appreciate any help!
DELETE
FROM Sandbox.SandboxTable
where
Date >= '2018-07-01T00:00:00' AND Date <= '2018-07-31T23:59:59'
Related
I have such an issue. I have a report that is built around today's date. We see data only from today. On Hand units from today.
However, we have many import issues and sometimes import fails and there is no data in this report. I was wondering if there may be a way to make it dynamic like to use MAX function with getdate() or anything similar. I always want to see data from today, however if there is no data available for today I would like to see the data from yesterday. If not from yesterday from a day before yesterday.
I need to change the date logic to just pull the data for the max date.
Does someone know how it can be done?
where sku.ohpost = cast(getdate()as date)
try this If column sku.ohpost type is date
where sku.ohpost = ( select max(sku.ohpost ) from mytable)
As the title says I'm trying to create a live dashboard in Tableau that updates every day showing the data for the last 7 days. I'm querying through SQL and then importing it in Tableau. Do I have to specify this requirement in my query or would there be some way to do it in the tableau itself. Thank you so much. I would really appreciate the help.
Disclaimer: I'm pretty novice in tableau and SQL.
If you have a date field in your table then you can use it as a filter and select relative date as the option for the filter and in the dialog that appears you can enter number of days for the days field. Since you want the live data for the last 7 days, you can enter 7 and you'll get the updated data each time.
If you are querying through SQL, put the filter for date/ timestamp in where condition itself like so:
DATE(date_column_filter) >= (DATE(NOW()) - INTERVAL 7 DAY)
pretty new to posting here so be gentle :p
I run monthly queries for SOX compliance reporting. My manager wants me to adjust the query so that we do not have to manually change the date range to the applicable month every time we run them. What would be method to automate this task so I dont have to manually change the date range prior to running the query. I have a .bat .log and spool my results to a .csv using sqlplus. Thanks for any help!!
You can use the getdate() function to return todays date, and then build from there.
WHERE MONTH(thingDate) = MONTH(getdate())
and YEAR(thingDate) = YEAR(getdate())
The last_day function is helpful for retrieving the last day of the current month. There is no simple function for the first day, but a simple function such as this will do the trick:
to_char(TRUNC(SYSDATE, 'MM'), 'DD-MON-YYYY')
So using both of those with the BETWEEN operator in your WHERE clause will get you where you need to be. You'll just need to possibly change the date format for your situation.
I have a view that lists employee (EmpID), request number (ReqNo), date request was opened (OpenDate) and the date it was moved to the next step in the process (AssignDate). What I am trying to do is get an average of the daily queue size. If EmpID 001 has 20 requests on 1/1/13, then has 24 on 1/2/13, 21 on 1/3/13 the average over 3 days should be 21.66, rounded up to 22. I have the following view:
CREATE VIEW EmpReqs
AS
SELECT [EmpID], [OpenDate], [AssignDate], [ReqID]
FROM [Metrics].[dbo].[Assignments]
WHERE OpenDate BETWEEN '01/01/2013' AND '12/31/2013' AND
[EmpID] IS NOT NULL AND
[ReqNo] NOT LIKE 'M%'
I then wrote a query to pull individual employee's queues per day:
/* First attempt to generate daily queue #s */
SELECT * FROM BLReqs
WHERE [BusLiaison] LIKE 'PN' AND
[OpenDate] <= '11/15/2013' AND
[AssignDate] > '11/15/2013'
Because no one has attempted to pull this information before, I have no way of verifying how accurate the above is. I tried using current dates, since I can see those in our database to compare but the code doesn't work, nothing is returned when I change the dates to 2014 and run my query.
What is the easiest way to verify that my code is correct, short of manually counting a day's queue?
Can anyone see any issues with the above scripts?
Is there a way to get the above code to work with current dates?
This question is really hard to answer because it is kind of broad and has little information at the same time. I'll try anyway:
Because no one has attempted to pull this information before, I have
no way of verifying how accurate the above is.
Try checking the result of this query for a few sampled dates.
I tried using current dates, since I can see those in our database to
compare but the code doesn't work, nothing is returned when I change
the dates to 2014 and run my query.
So clearly, the query is not working. You should probably find out why. Run the query for a date of which you know that it should return results but doesn't. Remove conditions one by one to see which one is incorrectly removing all rows. This should be enough to identify the bug.
Can anyone see any issues with the above scripts?
No, looks fine. A very simple query. That's why I said that we have too little information. There is some key piece of information missing that allows us to find the bug.
Is there a way to get the above code to work with current dates?
Stop staring at the code and hoping for a revelation. Debug it. Experiment.
I have a Calendar List and I am querying it via Content Query Web Part, but when I try to filter based on Start and End Dates, I dont see these columns under Additional Filters.
Anyone has any idea how can solve this problem?
Thank you.
Never tried this before but my suggestion is to
Try filter based on Modified Date 1st , if it works then Start Date , End Date should also work