Query to retrieve data of specific date in MSAccess - ms-access

I want to retrieve of particular date. For example my database has data from 1st-Jan to 31-AUG. I want to fetch data of 1st two months. Please suggest me helping query for this purpose thanks.

Open the query design window, add your table, double-click fields to add them to the grid. Type a date into the criteria line underneath the date field you added.

SQL query:
select *
from table
where table.my_date <= #29/02/2012#
will filter date before 29 feb. In query window you can type <=#29/02/2012#

Related

Is there a way to know the number of records added into the SQL database after a particular date and time

The table doesn't have any date time column. I want to if there is any inbuilt keyword which can does that.
I want to know all commits done after a particular date.
If flashback is enabled on the database you can get records on the table in an around a particular date range in Oracle.(It purely depends on if its enabled and for how long the flashback needs to be kept)
You can query to see the data in the table as of 3 days back as follows
select *
from table as of timestamp sysdate-3

Sort differing date formats in Access?

I have an Access database in which a report is pulled and displayed based on city and state. There is a form where the user selects city and state and a query is run, then a report displayed based on that query. I want to sort the data from the query by Warranty Start date(WSD) then Model #. The problem is that all of the dates aren't in the same format and if I try to format the WSD column as a date field Access Deletes at least 1000 records. Currently all fields are formatted as short text. Is there a way that I can sort the data by date without the format being the same for all? I have attached a screenshot of some records to show the issue.
If you need the sql query I can provide that as well.
If you wish to sort by the date, then you can use:
IIf(IsDate([WSD]), CDate([WSD]), DateSerial(Val([WSD]),1,1)) AS WarrantyDate

How to create a Multiple date picker for a search form

I am quite a newbie to MS Access.I am working with a search form in MS Access and I want to create a date picker in which I can select multiple dates which will be an input for a Query that is used to search and display the results from my table for the records that have the selected dates. I did some research on this,however I was unable to find out a feasible solution for my problem.
As I see there are only 2 ways in which this can be done.The first way is that is using two date pickers one for from date and other for to date and then search for the records between these days which is not very feasible for my scenario as I might want to choose two different dates for example 4th of Jan and 6th of Jan and display results for only those days.
The other method is to use a list box which displays all the dates that are present in the database and choose from that however this is not going to work for me as if I have a very long list of dates such as from 1st Jan to 31st Jan then it would be very time consuming and also I might select a date which I do not want to to search for also in the results.
Could anybody suggest me how can I solve this problem.I am looking for a multiple date picker property in access.Is it possible to achieve this through the form properties? If yes how can it be done? Or is there any other solution for this problem?
Thanks in Advance.
I would recommend creating a temp table consisting of two fields, a Yes/No field and a Date field. Populate the date field (don't name it 'date') with all of the dates from your list of dates. Then on your search form add a subform bound to the temp table. Users would simply check the box next to the desired dates. Then modify your query to include the temp table with a join on the date fields and criteria that the Yes/No field is True (Yes).
Its doubtful youre still looking for this but for anyone else that happens accross this topic I modified an existing datepicker to allow selection of any number of non-contiguous dates, and insert them to a table. I posted it on UtterAccess (A great forum for Access questions). A link to the forum topic is below, but you need to create an account to download the example file.
http://www.utteraccess.com/forum/index.php?showtopic=1738361&st=0#entry2535392
You could combine the two approaches and have
Two textboxes to filter for a short date range (say 1 month dates)
Show the dates in this date range in a multiselect listbox where the user can select the specific dates they need.

Determine table based on prompt

PostPosted: 09 May 2014 22:26
Post subject: Determine table based on prompt
Hello,
I have three fact tables. First table holds current data, FACT_CUSTOMER_CURRENT. Other two tables hold historical snapshots. For example, one of these table holds last 60 days' records- FACT_CUSTOMER_DAILY. The other table holds data for the last day of the months.-FACT_CUSTOMER_MONTHLY
I want to add a date prompt. If the user selects yesterday as a prompt value, report should bring value from first table which holds current data (FACT_CUSTOMER_CURRENT). If user enters 28.02.2014, the report should retrieve data from FACT_CUSTOMER_MONTHLY. I tried to use context and aggregate awareness, but I could not be successful.
Can you help me?
Kind regards
There's no direct, easy way to do what you want.
Aggregate Awareness is useful for selecting a table based on the selection of objects in a query, but it does not support dynamic selection of tables based on values in a prompt.
If yesterday's data will only exist in fact_customer_current, then you can use this method: In your report, create a UNION query. One query includes objects from fact_customer_current, and the other from fact_customer_monthly. They both have an identical prompt on the appropriate date field. When a user enters yesterday's date, the first UNION query will return data but the second one won't. Likewise for date before yesterday, the first UNION will return no data but the second one will. This solution requires that the tables are correctly indexed such that a query on a date that isn't in the table will return quickly.

Customize Mysql DB fetch in Office Excel

I am able to fetch a sql query from excel using the odbc connection:
But the issue is that, instead of just give a stack query setup and make user can only click the refresh button, I wish I could have some fields before the result, which user can enter some custom variables(e.g date from, date to)
so when they click refresh button, excel will take the variables of what user inputted into the pre-defined sql query and fetch the result from my sql server.
To do this sort of thing you need to run one query to fetch the initial values of your custom variables from the DBMS. For example, if you want to let the user change the date range, do this.
Use a query fetch the minimum and maximum date from the date column of your table.
SELECT MIN(date) mindate, MAX(date) maxdate
FROM table
Display those dates and let the user edit them on your form.
Put the results of those edited items into your second query, and retrieve the data the user asked for.
SELECT (whatever)
FROM table
WHERE date BETWEEN user-min-date AND user-max-date
The same kind of steps will work to populate a dropdown or listbox with a category
SELECT DISTINCT category
FROM table
ORDER BY category
Then
SELECT (whatever)
FROM table
WHERE category = user-selected-category
I think this addresses your question. Please clarify if it doesn't.