Is is possible in a Table to Calculate differences between Dates if the Value in the field is considered "short text"?
I am working to convert an Excel macro database into Access one and I have imported the data from the Excel file into an Access Table.
however i realized 2 feilds that count up until closure are now just fixed numbers but need to add up as each day passes until closure
when i imported the Dates became Short Text.
is there an expression that would handle this situation?
Each record has a serialized non repeating ID number seperate from access as well.
Dates I have are
OfficialissuanceDate,
DatePlanSubmitted,
DatePlanCompletedSubmitted,
DateClosed,
I need 2 calculations that increments daily when DateplanSubmitted and DatePlanCompletedSubmitted are null
Both comparing to OfficialIssuanceDate. then stop counting when they are no longer null. (have a date in updated to the record) and retain the value.
I have tried to Google calculating Dates but i get DateDiff function which doesnt appear to work. I've used Access and taken a class on it but never really made a new DB from scratch
Dates in a text field are not actual dates, just strings of characters. A Date/Time field stores value as a double number then displays in a date structure - "dd/mm/yyyy" is Access default structure.
Sometimes Access will do implicit conversion of data but not in this case. Either change field type to Date/Time or do conversion with CDate() function. However, you will find that conversion functions error with Null input.
Arithmetic operation with Date/Time field type is possible. However, arithmetic when any term is null returns Null so have to deal with that. One way uses Nz() function: Nz([DateClosed], Date()) - [DateOpened]. Unfortunately, Nz() is not available in table Calculated field type, so do that calc in query or textbox. Most developers avoid table Calculated field type. If you really want to use, expression would have to be: IIf(IsNull([DateClosed), Date(), [DateClosed]) - [DateOpened].
Related
I have an Access data table with the Field "RequiredUntil", which is from the type "Date/Time", and several other columns, and a form, in which I show that table, and where I usually use right mouse click to filter for what I want. The text box for "RequiredUntil" is formatted as "Short Date".
Part of the form:
When I now do a right click on the field "RequiredUntil" in that form, Access properly recognizes that as a date, and offers me several date filters, i.e. Today, "This week", Past,... So I don't use any SQL there, all is done by Access!
When I select "Today" (or Yesterday or Tomorrow), I get a "Data type mismatch in criteria expression" error.
When I select "This week" (or any other time period), the filter is properly set - but as soon as I filter the next column, I get a
Syntax Error in Query expression '((Year([DataTable].[RequiredUntil])=Year(Date())) AND
(DatePart("ww";[DataTable].[RequiredUntil];0)=DatePart("ww",Date(),0))'.
In that case, the date filter is revoked, and only the second filter is applied.
So, I don't do any SQL, RequiredUntil is of the type Date/Time, the text field in the Form is Date/Time, Access recognizes it as Date - what am I missing?
I'm pretty sure, the issue is caused by Null values in your date field.
If removed, you can set the filter, which will reveal as:
(DateSerial(Year([DataTable].[RequiredUntil]), Month([DataTable].[RequiredUntil]), Day([DataTable].[RequiredUntil])) = Date()+1)
which, obviously, will fail, as DateSerial doesn't accept Null values.
When I'm fetching data from my access database with pyodbc, it returns false format for float, date, or integers.
For example:
These values
Are returned like this
I've been searching for a long time now, I think it comes from the ODBC Driver used, but realy, I have no clue.
Another example would be a date like "21/01/2021" of type DATE in my MS Access DB, will be returned as a datetime in chinese or korean format YYYY-mm-dd H:m:s.
Floating-point columns (Numeric(Double) and Numeric(Single)) will display all decimal places in the Access UI if the field definitions in the table use the default formatting options
Format: (empty)
Decimal Places: Auto
Changing those settings to
Format: Fixed
Decimal Places: 2
will change the display format in the Access UI but the number itself will still be stored with its full precision. The ODBC driver does not pay attention to those formatting properties, so it returns the values with all available decimal places.
As for Date/Time values, the default format in the Access UI is to display just the date if the time component is exactly midnight. However the Date/Time value is stored with that time component (00:00:00) and again, the ODBC driver returns the complete value. See this answer for a more detailed explanation.
Good Day,
i have an MS Access DB that has 1 column that contains dates and strings (in different cells). my question is if it is possible to filter by date as date while keeping the strings? the column looks like this:
Date_Col
01/05/15
05/04/18
Not Released
01/01/18
Not Released
this is data from hardware EOL so we need to keep the dates and the strings but we need to have the ability to filter or sort the dates as we wish.
any help would be appreciated as right now when i am trying to filter the column is treating everything as text but if the column was in excel it will filter by date and ignore the strings cells.
You can use a query where you convert that text field to a true date value:
Select *, CDate([Date_Col]) As TrueDate
From YourTable
Where IsDate([Date_Col])
Now, filter on field TrueDate as you like.
I want to transform the value of fields name and Date using pentaho(kattle) and store it in standard format in any table.
For example
id,name,f_n,Date
1,j_vick,03-05-2015
2,jo_vick,04,08,2016
3,Arn_jonnn_vick,05,07,2017
Now I want to transform it using pentaho(kattle) IDE and store it in data base like below:
id,name,Date
1,john_vick,03/05/2015
2,john_vick,04/08/2016
3,Arn_john_vick,05/07/2017
I don't want the transformation steps concern with extraction database storage.
The date format is just some clothing of a value. Just read it with Kettle and store it as is. The database will store it in its proper internal binary format anyway.
Unless, you have to store them explicitly as varchar. In that case, use the Metadata tab of the Select Value step. Define your column as Date and specify the format as dd/MM/yyyy or MM/dd/yyyy. It will be kept internally as a Date, and converted into a String with the selected format at the last moment.
You also seam to have an other problem: the day, month and year are in three columns. The easiest way is to use a Modified Java Script Value step, in which you define a new column date = new Date(year, month, year), with type Date, and let Kettle handle with the format.
Maybe you have mixed input, in which case you can use a Filter or a Swtich step, based on weather you have something in the day and month column.
When that is done, you can make a job that runs the transformation on all the tables. You have an example in the sample/jobs/process all tables furnished with the Pentaho Data Integrator (aka Kettle).
I cannot work out why these Total expressions don't work...
I am trying to add any cells that have a date later than today, with any cells that have "Not Reqd", and then divide that by the number of rows, to get a percentage.
All I'm getting is #Error.
These are the expressions I've tried:
=SUM(IIf(Fields!Jetter_Trng.Value >Today OR
Fields!Jetter_Trng.Value = "Not Reqd",1,0)))/(Count(Fields!Jetter_Trng.Value)
and
=Count(IIf(Fields!Jetter_Trng.Value >Today OR
Fields!Jetter_Trng.Value = "Not Reqd",1,Nothing)))/(Count(Fields!Jetter_Trng.Value)
The "Not Reqd" string has come from an expression that changes a date (01/01/1950) to "Not Reqd". Maybe this is messing things up:
=iif(Fields!Jetter_Trng.Value = "01/01/1950", "Not Reqd", Fields!Jetter_Trng.Value)
The current working expression (not looking for "Not Reqd") is:
=COUNT(IIF(Fields!Jetter_Trng.Value>Today,1,Nothing)))/(Count(Fields!Name.Value))
I'm a bit lost...
A couple of notes on your expression as it stands at present
Jetter_Trng appears to be a string representing either a date or “Not Reqd”. You can’t compare strings to dates without casting them to a date type first using CDATE()
The number of braces (( and )) do not match
The root of your problem though is that you are using Jetter_Trng to return either a Date, or the value “Not Reqd”.
When SSRS attempts to evaluate an expression it does it all at the same time. It doesn’t follow a path to find the answer, and ignore other paths. Therefore, when you are attempting to compare
Fields!Jetter_Trng.Value >Today
This is comparing a string to a date, and throwing the error, as this mean nothing
"Not Reqd" > Today
You won’t be able to do all that you want to using only one Field of type string.
Your options are to
Use two fields – the date and a flag indicating not required, or
Use one field – but have an “invalid date” (01/01/2100 perhaps) that you could then treat as the “Not Reqd” value, and check if the current date is less than that (which it always will be)
Using the second option here you could then use the following expression to create the desired calculation
=sum(iif(CDate(Fields!Jetter_Trng.Value) > Today, 1, 0)) /
Count(Fields!Jetter_Trng.Value)
Which would evaluate this dataset as follows