I have a computed column known as TotalTime. This column is populated using the DATEDIFF function from two datapoints that we are getting entered in from Microsoft PowerApps - StartTime and EndTime.
However, sometimes it would be nice to be able to make adjustments to the calculation. For example, if the PowerApps user selects a certain control, it would add five minutes to TotalTime.
This doesn't necessarily have to come from PowerApps itself - but could be a stored proc or function. What is the cleanest way to do this without having to break the computed column?
Add a new column (TotalTimeAdjustment) reserved for admin adjustment. This will be normally NULL (or can be defaulted to 0). Modify your calculated column to include TotalTimeAdjustment column as the 3rd input alongside StartTime and EndTime. Whenever an adjustment is needed the admin can update TotalTimeAdjustment for the relevant record(s).
Related
Is it possible to store a variable in a SQL table which will only take effect once a certain date is reached? The variable is the amount of days that would be added to a date to create a "TargetDate", this variable can be changed by user input but must have an "EffectiveDate" ?
You can certainly create a configuration table that you store config data in. In your case, one of the items would be 'EFCTV_BUFFER' as the value in the key column, and (for an example) '5' as the number of days in the value column. Then you can reference that key value to select the buffer days value, and add that to whatever date you want.
This allows you to modify it at any time as requested.
You would reference this table in an insert/update trigger on your table where you store your dates. I would suggest having two dates so that the calculation is only done once, unless you need the calculation to be dynamic based upon the current 'EFCTV_BUFFER' configuration value.
I have a table with a bunch of different fields. One is named period.
The period is not part of the raw data but I run a query when I import new data to the database that gives each record a period.
Now I need a delete query that will delete all the records that have the same period as what is selected in a combobox.
The values in the combobox come from a calendar table that contain all the possible values that could be in that period column at any time.
This is the basic query i thought would solve this issue but it tells me it is going to delete 0 rows every time I run it:
DELETE *
FROM PlanTemp
WHERE PlanTemp.period = Forms![Plan Form]!Combo163;
If you don't need the key field, just remove it.
Look at the "PROPERTIES" section and look at the column names.
Ether remove it there, or from your QUERY source.
You can also look at the Data section of the properties, and change your BOUND column, to Column 2... or whatever holds the data you want to use.
For auto date\time we use TIMESTAMP datatype in SQL. What is equivalent to that datatype in MS Access 2007...
There is no exact equivalent in Access.
To clarify, TIMESTAMP in SQL is not always a usable Date/Time, for instance in SQL Server it is deprecated and equivalent to ROWVERSION, which always returns a unique value and it not used to track date and time, even though its value is loosely derived from the current time.
But let's say you want to track changes to records.
In Access, the following ways let you set a field to a DateTime automatically:
First, you can assign =Now as the default value for a DateTime field in a table. This will assign the current time when the record is created (but will not update it automatically when the record is changed).
For recording the current DateTime whenever you make a change, you will have to program that in VBA or through Macros:
When going through a recordset, just update your !ModifiedDateTime or (whatever you called your field) whenever you make a change to a record.
When your table/query is bound to a form, you can let the form update your ModifiedDateTime field by handling the BeforeUpdate event of the form:
Private Sub Form_BeforeUpdate(Cancel As Integer)
ModifiedDateTime = Now
End Sub
If you use a query rather than a table to bind to the form, make sure that the field is present in the query.
In Access 2010 and later, you may also use the new Data Macro, which are the Access equivalent of triggers, to record the current date and time when a record changes.
This is less portable, but would probably be more reliable than using VBA since you don't have to remember to code it whenever you modify a record (Data Macros are handled at the ACE database driver level).
There are tons of articles on how to create audit trails in Access if that is what you are looking for.
DateTime is the only date-based datatype in Access. You would then format the field to either General Date or Long Time to capture down to seconds. I don't think Access gets more accurate than that.
In Crystal Reports, I want to add a WHERE field <> date to filter out dates that have a NULL value from my database in my report.
I'm using a legacy FoxPro database on the backend which generates an SQL statement from my report, but doesn't appear to have anyway of adding a WHERE clause to the generated statement.
When accessing the FoxPro backend directly, dates with psudo-NULL values have a date of 1899-12-30, but when they are pulled from FoxPro through Crystal they appear as 12/30/99 (which is maybe the same date just displayed in MM/DD/YY format).
I noticed that the report had an existing Parameter Field that prompts the user to filter out the original query down to a specific date range. I tried to add my own in addition to the Parameter Field, but discovered that what I needed with my WHERE field <> date is not an available option since there are only 3 types of Field Parameters mainly:
Discrete
Accept single and discrete values.
Ranged
Accept a lower and upper value in order to select everything in this range.
Discrete and Ranged
A combination of the two above
None of these appear able to filter the results of the query using a WHERE NOT type of clause, is there some other way to do this?
Add this to your record-selection formula:
// remove actual nulls
AND Not(Isnull({table.date_field}))
// remove old dates
AND {table.field} <> date(1899,12,30)
// remove dates not in select parameter value
AND {table.field} IN {#date_parameter}
All I really needed to do was add some criteria to the WHERE clause of the SQL statement, simple enough in an SQL client, but when you're doing this in Crystal Reports v10 it's a bit difficult to find, unless you know what you are looking for...
So what I needed to do was:
Select the field to filter by in the report (in the Details section)
Click the Select Expert button on the Experts toolbar.
In the Select Expert dialog the name of your field should appear in a tab.
Below you can select the WHERE criteria used to filter the records.
I have 300+ queries which fetch information from my database. Right now, there is no time condition specified in the queries, so if I wanted to filter all of them by a certain time period, i.e. Between #07/01/2009# And #08/01/2009#, I would have to manually go in each query and add this condition.
All of my queries are populating data into 4 main reports. What I am trying to do is apply a time filtering criteria like the one above to all of my queries at once, so that I can create a weekly report, as well as the Totals report (which just means there's no time condition).
Is there any easy way to add a single parameter before pulling my report that would filter all of my queries at once, and to pull the Totals report if it the parameter field were blank?
You can use a reference to a form control within the WHERE clause of a query. So, for example, if I have an open form named frmDatePicker which includes a text box control named txtStartdate, I could use that control's value as a WHERE condition.
SELECT *
FROM MyTable
WHERE my_date_field >= Forms!frmDatePicker!txtStartDate;
That approach can work, but I have no idea whether it's an appropriate fit for your situation. You would have to modify all of your queries which include that date condition. That could be a one-time-only change. But if you ever change the form and/or control name, you'd have the revise the queries again. (So try not to do that!)
Edit: If you want to allow the user to leave txtStartDate blank, so as not to filter on that date at all, try a WHERE clause like this:
WHERE
my_date_field >= Forms!frmDatePicker!txtStartDate
Or Forms!frmDatePicker!txtStartDate Is Null;