SAP GRC case start date and due date location in tables - sap

Good afternoon,
Does anyone know in which table are stored a test control effectiveness planner case start date and due date in SAP GRC?
The CREATE_TIME of the SCMG_T_CASE_ATTR table refers to the moment that this form is filled and the plan activated, not to the control start date.
The DUE_DATE of the GRPCCASETL table is not always filled. It shows 00000000 many times.
Does anybody know in which table are the two dates in the red square stored?

Related

Power BI: Measure for Date difference depending on other columns

I hope everybody is doing fine! :)
I have a table like the one in my "Example" picture. Let's say it is data about certain products and a certain assembly status (i.e. column "Status"). In "Status Date" I can see the date on which the product has been in the specific status. I only added dates for ID 1 to make the table easier.
Table
What I am looking for is a measure in Power BI to calculate the difference (in days or month doesn't matter) between the dates. I don't want to use the number in the Status (e.g. 1 for Stat 1) to identify the order of the dates. To make it even harder, I may want to filter out Stat 2 for some reason. In that case I want the measure to automatically adapt and calculate the difference between Stat 3 and Stat 1.
I have the feeling that this is possible in a single formular using a measure which would be the optimal solution from my point of view.
I hope there's someone who can help me!
Thanks in advance.
Daniel

Check whether a form date field is equal to 1899-12-30 00:00:00.000

I know this should be simple but after hours of googling I am still failing...
I have a vb.net form application. Basically I have an SQL database with an Employee table with an EmpFinish column in datetime, null format (Employee Finish Date). The data is imported from a linked SQL DB (populated from an external app). Any "blank" dates show as 1899-12-30 00:00:00.000 in SQL.
The Employee table data is shown on a datagridview form, a row is selected, then I want to perform a check to test whether that rows EmpFinish date from the form is earlier or equal to today and is not equal to it's "blank" value i.e. has the employee left employment.
Code excerpt:
Dim currentDateTime = DateTime.Now
Dim selectedEmpFinishDate As DateTime =
EmployeesDataGridView.SelectedRows(0).Cells(5).Value
If selectedEmpFinishDate.CompareTo(currentDateTime) <= 0 Then
' code to do
End If
I didn't start out using the CompareTo() above util I started Googling this issue and it seems this is the best way to compare dates. Yes???
This test works for actual dates e.g. yesterday but also catches all 1899 dates, I have tried lots of tests (using 1 If statement of separate ones) to check for the 1899 blank dates but cannot get anything to work. If I debug the code at the test line, selectedEmpFinishDate supposedly equals #12/30/1899#. If I show the field value onscreen via
MsgBox("selectedFinDate = " & selectedEmpFinishDate) it reports as 00:00:00
I know this must be possible but cannot figure it out.
Could someone please offer a solution as I am running out of hair to pull out.
I have followed djv's advice (I had the same thought last night) and done an override to set these date values to NULL. I was then able to use IsDBNull() successfully.
To clarify where these dates came from... Data is imported into this database from another SQL DB created by a huge business software application. Not sure if they want the dates stored this way or whether the import sets them to be this "blank" default 1899 date.
They actually showed on all forms as 1899 etc so resetting them to NULL is the best option all around.
To anyone else who has these 1899 dates I would advise to update them to NULL.
Thank you to everyone who responded especially djv.

SQL query for limiting records

I have following SQL query in Data Flow, Control flow of SSIS package and I want to limit records by cutting off point, and that cut off point is current day/date from system. So, it should only display past records, not including todays. So, I think I need to use the specific field (which is date field - in the query its called 'FinalCloseDate' and compare with current system date and tell it to only to pull the records (perhaps < todays date) that happened before today or current system day.
Add
AND dbo.Producthit.FinalCloseDate < CAST(GETDATE() AS DATE)
to your WHERE clause.

Best way to pull data

We have a SQL table that stores the date an email was created and then another table that gives details about that email (how long they spent writing the email, how long it was in a Draft mode etc). The join between the two tables is through a key.
The problem is, it only stores the date the email was created (entered into the system) and data is only written to the table when the email is completed (sent). So for yesterday, you may have 1000 emails completed that day, but their create date and time is varied. Also the create date time column is only in one table.
My method right now is to join the two tables, and in the where clause I calculate the completed date by adding the number of seconds of the email write time to the created date time.
WHERE DATEADD(s, ISNULL(a.emailwritetime,0), b.CreateDateTime) BETWEEN #start AND #end
(#start and #end are usually the previous day)
The tables have millions of rows, so expectedly, this takes a while to run and its hitting the production server to pull the data. Can anyone suggest a better/cleaner way of pulling the data? If you dont know what createdatetimes finished yesterday?
You should probably use a computed column for the value you're looking for.

Opening Hours Database Design

We are currently developing an application in which multiple entities have associated opening hours. Opening hours may span multiple days, or may be contained within a single day.
Ex. Opens Monday at 6:00 and closes at Friday at 18:00.
Or
Opens Monday at 06:00 and closes Monday at 15:00.
Also, an entity may have multiple sets of opening hours per day.
So far, the best design I have found, is to define an opening hour to consist of the following:
StartDay, StartTime, EndDay and EndTime.
This design allows for all the needed flexibility. However, data integrity becomes an issue. I cannot seem to find a solution that will disallow overlapping spans (in the database).
Please share your thoughts.
EDIT: The database is Microsoft SQL Server 2008 R2
Consider storing your StartDay and StartTime, but then have a value for the number of hours that it's open. This will ensure that your closing datetime is after the opening.
OpenDate -- day of week? e.g. 1 for Monday
OpenTime -- time of day. e.g. 08:00
DurationInHours -- in hours or mins. e.g. 15.5
Presuming a robust trigger framework
On insert/update you would check if the new start or end date falls inside of any existing range. If it does then you would roll back the change.
CREATE TRIGGER [dbo].[mytable_iutrig] on [mytable] FOR INSERT, UPDATE AS
IF (SELECT COUNT(*)
FROM inserted, mytable
WHERE (inserted.startdate < mytable.enddate
AND inserted.startdate > mytable.startdate)
OR (inserted.enddate < mytable.enddate
AND inserted.enddate > mytable.startdate)) > 0
BEGIN
RAISERROR --error number
ROLLBACK TRANSACTION
END
Detecting and preventing overlapping time periods will have to be done at the application level. Of course you can attempt to use a trigger in the database but in my opinion this is not a database issue. The structure that you came up with is fine, but your application logic will have to take care of the overlap.
There's an article by Joe Celko on the SimpleTalk website, over here, that discusses a similar issue, and presents am elegant if complex solution. This is probably applicable to your situation.
A table with a single column TimeOfChangeBetweenOpeningAndClosing?
More seriously though, I would probably not worry too much about coming up with a single database structure for representing everything, eventually you'll probably want want a system involving recurrences, planned closures etc. Persist objects representing those, and then evaluate them to find out the closing/opening times.
This looks like a good solution, but you'll have to write a custom validation function. The built in database validation (i.e. unique, less than x, etc.) isn't going to cut it here. To ensure you don't have overlapping spans, every time you insert a record into the database, you're going to have to select existing records and compare...
First the logic, two spans will overlap if the start value of one falls between the start/end of the other. This is much easier if we have datetimes combined, instead of date1,time1 and date2,time2. So a query to find an overlap looks like this.
select openingId
from opening o1
join opening o2 on o1.startDateTime
between o2.startDateTime
AND o2.endDateTime
You can put this into a trigger and throw an error if a match is found.