Advanced DataGridView DateTime Filter - vb.net

In my win form application I have used 'Advanced DataGridView'. For filter string columns it is working good but when i filter Datetime column the grid view becomes empty.
When i did debug it, i came to known that it is getting only dates and not dateTime from the column i.e
([Date_Time] IN ('11/04/2017', '12/04/2017', '13/04/2017'))
and this is the reason why my grid view become empty because there is no row with only date.
here is my code for 'Change filterString' event
Me.crossMatchBindingSource.Filter = dgvCrossMatchDetails.FilterString
So, my question is how can i include time in the filter.

I believe you are trying to bind a grid view to a data source, which uses SQL to extract data from the databases. I believe you can just amend your SQL as follows:
([Date_Time] between ('11/04/2017' and '14/04/2017'))
This should cater for times as well as dates.

You should just go to DataGridView properties and set "DateWithTime" to "True".
Then you are able to filter by Date and Time now.

Please correct me if i m wrong. whoever created AdvancedDataGrid, the code he/she wrote to filter can only filter the date and not the datetime. So i should split my datetime in two columns then i will be able to filter my dates. Actually i have done it and it is working perfectly but time column shows every record separately like text in the filter and not making grope of hours and minutes as excel does.

Related

MS-Access conditional format date in tabular forms row by row

I have created a database to store genealogical records. I have created a tabular form to display records which include a date text box, however I am struggling to display the date text boxes with the formatting different on each row. The different formats I require are "dd/mm/yyyy" where a full date is known, "yyyy" where the year only is known, and the text box to be left blank if the date is unknown. The table the form is aligned to has a field to indicate whether the date is a full date, year only, or no date - field values "fd", "yo" and "nd" so easy to test the format required for each row.
I cannot see how this is possible using the Conditional Format option.
I am happy to use VBA but have struggled with this. I am new to Access and new to VBA but have a technical background (coding in C++ and Java) and VBA currently looks alien to me - but willing to get into it.
Any pointers please will be much appreciated.
Always store dates as DateTime as it can be stored as Null for unknown.
Then, have a Boolean field, YearOnly, to mark values where only the year is known; store the year with any date of the year, like 2020-01-01.
Now, use a query like this:
SELECT
ID,
[Date],
YearOnly,
Format([Date],"yyyy" & IIf(Not [YearOnly],"-mm-dd")) AS DisplayDate
FROM
YourTable;
[Solved] Thank you Kostas K and Gustav, I have implemented the query you suggest, which took me a while to figure out, but I have it now working in my tabular form. My problem was I was trying to achieve this using VBA on loading the form. VBA wise I am a complete novice.
Thanks Bob H

Visualizing last refresh date in power bi

Is it possible to add a card in power BI that shows the last time the underneath dataset has been updated?
Many thanks!
You can create a blank query and use the following M query to create a single-cell table:
let
Source = #table(type table[Last Refresh=datetime], {{DateTime.LocalNow()}})
in
Source
And then you can use the Card visual and drag in the column to show it. You can rename the field to remove the default aggregation. (It doesn't matter since there is only one row of data anyways)
The value will be recalculated each time the data is refreshed.
you can achieve this by adding a calculated column (Refresh data Column) in the model with the formula =NOW()
Then add measure
Last Refresh Date :=MAX(Table[Last Refresh Column])
Since calculated columns are calculated only on model refresh - it will make sure the calculation is right.
The below code is working for me (for HK).
Add a column with the below formula
Last Refresh = FORMAT(UTCNOW()+TIME(8,0,0),"dd MMMM YYYY ttttt")
Depending on the location it's really confusing with all those functions..
Let me suggest you the workable one:
Go to the:
Query Editor
1.right click on the Queries body on the left side
2.new queries
3.Blank Queries
4.Paste the following formula by putting the right Server Instances and DB Name,
" = Sql.Database("Server\Instance", "Database", [Query="select GETDATE() LastRefreshDate from AnyTableName"])
It'll work out. And since it's pulling directly from the server,, you don't have to worry about choosing the right DateTimeZone functions in PowerBI.

Excel SQL import - date format not appearing and time format auto-change. Annoying

I'm working on a Excel application that will obtain data from my Entry form and import it into a Display sheet, both in separate worksheets.
The Entry form has a table to key in data via a combination of manual key-in, dropdown lists and vlookup functions. This table is then defined as EntryTable..
In the Summary form there is an SQL statement (SQL1) used to import the data from Entry to Display.
However every time I click the button, the Entry Date will not appear, and the Time changes its format to include date and time.
What's more for some reason the time format in Entry also changes as well. To add insult to injury.
Basically my question here is:
Why was Entry Date omitted in the search even though the SQL specifically stated to select all?
Why does the time always have to add a date in the format every time I try to import?
If anyone know what the issue is, please share with me. Because I'm all out of ideas and I'm losing my patience.

Need Date Calculation MS Access

I need a flexible table that displays dates. By flexible, I mean, if I put in June 15, 1976, it displays as such. But if I put 20, Access calculates that 20 in the same field as today's date - 20 years.
I set the formatting of the date/time field in table: tbl_ageLimit to #, so it displays a serial date rather than a user readable date. This table has one field: ageLimit.
I am trying to develop a query to recognize if the date is not relevant in its current state and then convert it to something relevant and put it in another table that will constantly update.
Right now, I'm just trying to get formula to work on recognizing and converting the date. This is the formula that works splendidly in excel, but doesn't seem to be working in MS Access:
IIF([ageLimit]<=100,Date()-365*[ageLimit],[ageLimit])
It recognizes if the field has a number in it that is less than 100. But it's not doing the math and displaying a new record in the new table. Below is the sql:
SELECT tbl_ageLimit.ageLimit INTO tbl_allAges
FROM tbl_ageLimit
WHERE (((tbl_ageLimit.ageLimit)=IIf([ageLimit]<=100,Date()-365*[ageLimit],[ageLimit])));
Can someone kindly point out to me what I'm doing wrong? Thank you.
As requested, here are snapshots of the problem:
The table that is created is not showing the fifth record. Stumped.
Consider removing the WHERE clause as you do not need to filter records. Since you intend to evaluate the IIF() expression, place in the SELECT clause:
SELECT IIf([ageLimit]<=100, Date()-365*[ageLimit], [ageLimit]) As [age_Limit]
INTO tbl_allAges
FROM tbl_ageLimit

UltraWinGrid, on date filter select date column value changing format to MM/dd/yyyy from dd/MM/yyyy

I have infragistics2 v10.3.
I have ultra grid with two columns
|String|DateTime|
For DateTime I have custom formatting like "dd.MM.yyyy HH:mm" System Regional settings have short Date format like "dd-MMM-yy".
So grid shows 07.02.2013 14:00 and user See this.
The sytem have 07-Feb-13
When i want to filter all columns with text "fe" it is also shows me all rows which contains 07.02.2013.
During filtering it uses own formating and ignores my custom In InitializeLayout event we have done the following code to set date format for the StartDate column
e.Layout.Bands(0).Columns("StartDate").Style = Win.UltraWinGrid.ColumnStyle.Date
e.Layout.Bands(0).Columns("StartDate").Format = "dd/MM/yyyy"
e.Layout.Bands(0).Columns("StartDate").ButtonDisplayStyle = UltraWinGrid.ButtonDisplayStyle.Always
This date field column filter displaying based on Local system date format in opened calendar.
Please suggest me where I am doing wrong
As your are using string column type to store dates, I suspect how the dates are converted: 07/08/2015 is treated as August 7 or July 8?
You are setting the format for your grid but the data loaded in the DropDown may be in its original form as in the Database.
If you do not want to change the data type of your date column, I would advise that you set DateFormat within the select query as demonstrated in change-data-type-of-data-retrieved-by-select-query (but beware of the conversion errors or the date change scenario as pointed above)
If you are using SQL Server (I'm not sure about other databases) you can use a UDF (User Defined Function) in the select query as in this example of UDF on TechNet or this post on SO: using-udf-in-select-statement
Along with that don't forget to set the Format of your DropDown, if defined explicitly on initialize or on entering edit mode.
You need to set MaskInput property of the column like this:
e.Layout.Bands(0).Columns("StartDate").MaskInput = "dd/mm/yyyy";
Keep in mind when cell is in edit mode it uses an editor to display the edited value. So when you need to fix anything in edit mode you need to fix it in the editor.