Queries :: Missing Days - Creating Table With 31 Days Of Zero Values
Apr 3, 2013
Client has asked me to create a report showing summary of monthly sales by day. That was easy. I created a query for the month the user selected and then summarized and group the data by day. Client like the result but would like to see zeros on the report for non sales days. Non sales days are days like holidays and there are no sales.
I am thinking of creating an table with 31 days of zero values and then join the two tables in a query? Or, should I create a temporary table with code and then merge the two tables which the existing query which I can then use for the report?
I have a form where a start date is inputted (Inputfrm , StartDate) and a form where the end date of the process is recorded (Inspectionfrm , EndDate) and these both record in the table InputTbl as StartDate and EndDate respectively.
I have created a union query which shows a list of all the dates where there is work recorded (WorkingDatesQry and the column of list of unique dates is "WorkingDate"), and as we run a highly varied schedule depending on time of the year and order numbers I cannot just use a query which says Monday-Friday or Tuesday - Saturday.What I am trying to do is to find the number of days between StartDate and EndDate where there is a date recorded in the WorkingDates query.
i'm in the process of creating an Access database to import data in text files and then export the data as fixed width text files, this is now working fine
My next step is to be able to setup an "Archive" Table which will hold all the data i have imported across multiple import proceudres for the last 30 days, i then want to be able to "De-Dupe" any files i import against this to ensure i never load duplicate data.
I have problem with my code here. I am using this code to determine if the LogDate with a weekday of Sunday can be declare as Sunday Work or Regular Work. The 1st week of my entry can determine if the LogDate is Sunday then compute if it reaches a 7 days working, if he is absent even 1 (one) day in his previous working days within the week. His Sunday LogDate is considered as Regular Days instead of Sunday Work. Can anyone tell me what is wrong in this code?
The problem here is the computation of 7 days after 1 week. There should be a 7 days computation every week per month in able to declare Sunday Work or Regular Work. I tried this code but it did not work on 2nd week, 3rd week and 4th week of the month.
How come on 2nd week, Sunday (LogDate) is not considered as Sunday Work even he completed the 7 days (working days) per week? I need help on this ASAP Thanks
Tim
Below is the code i'm using for defining Regular days and Sunday Working Days:
Private Sub LogDate_AfterUpdate() Dim rst As DAO.Recordset, rs As DAO.Recordset Dim db As DAO.Database Dim dteToday As Date, dtePrior As Date Dim i As Integer
Set db = CurrentDb Set rst = db.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays", dbOpenSnapshot)
rst.FindFirst "[HolidayDate] = #" & dteToday & "#" 'See if the date entered is a holiday If rst.NoMatch Then Holiday.Value = 0 Else Holiday.Value = 1 End If If Weekday(dteToday) = vbSunday Then 'If dated entered is a Sunday determine if Dim strSQL As String 'it will be a regular day or a Sunday
I have a query and I need the records to display 3 working days before the 15 working day deadline.
I used the following in the criteria box below the received date field and it doesn't pull the correct number of workdays, it's pulling calendar days instead.
I have a query and I need the records to display 3 working days before the 15 working day deadline.
I used the following in the criteria box below the received date field and it doesn't pull the correct number of workdays, it's pulling calendar days instead.
I rent out a property , on the rental statement I have a field [Datepaid], [RentpaidFrom] and [rentpaidTo]. I would to have a field that can calculate the rent that is paid to show if the rent is in arrears or in Advance. I guess the code would be something like (datediff ???? etc) but i have no idea what it should be. the calculation should appear on the query as i.e.2 days in arrears or 12 days in advance etc
I'm new to VBA coding. A code below is copied from a friend of mine and I can't make it work. How to call up this function in my form. In my form I have 3 text boxes (StartDate, EndDate and NumOfWorkDays). My form is based on a table.
Please anyone who would help me on this, kindly give me the step by step procedure as I am really novice. Thanks in advance.
'*********** Code Start ************** Public Function WorkingDays(StartDate As Date, EndDate As Date) As Integer On Error GoTo Err_WorkingDays
Dim intCount As Integer
StartDate = StartDate + 1 'If you want to count the day of StartDate as the 1st day 'Comment out the line above
intCount = 0 Do While StartDate <= EndDate 'Make the above < and not <= to not count the EndDate
Select Case WeekDay(StartDate) Case Is = 1, 7 intCount = intCount Case Is = 2, 3, 4, 5, 6 intCount = intCount + 1 End Select StartDate = StartDate + 1 Loop WorkingDays = intCount
Exit_WorkingDays: Exit Function
Err_WorkingDays: Select Case Err
Case Else MsgBox Err.Description Resume Exit_WorkingDays End Select
I am using workdays to calculate time passed between two dates. I also have a table for Holidays that I don't want counted as work days. This is working well, but I would like my queries to show a null value instead of showing #Error when a date field is empty. Here is my coding in my Module.
Option Compare Database Option Explicit Public Function Workdays(ByRef startDate As Date, _ ByRef endDate As Date, _ Optional ByVal strHolidays As String = "Holidays" _ ) As Integer
I have a table of employees, and dates they worked on. These are seasonal employees who want to get in as many days as possible before the season ends, but regulation states they must take a compulsory rest day after x days.So I need to create a query that can return the list of employees, with a count of consecutive workdays up until current date.
If today is 20/09/2013, and Johnny worked on, 19, 18, 17, 15, 14, 13, his count must be 3, because he was absent on 16. Therefore only from 17 through 19 is regarded as consecutive.
If Peter worked 19, 18, 17, 16, 15, 14, 13, his count would be 7, because unlike Johnny, Peter still worked on 16.
In a query i have setup, i work out when a tenant is next due to pay their rent.
Looks like this
Tenant Last Payment Date Payment Terms Next Payment Date User1 01/07/13 Monthly 01/08/13 User2 01/07/13 Weekly 07/07/13
The next payment date is calculated using an IF statement and DateAdd in the query, so if it is weekly it adds 7 days, if it is monthly it adds 1 month.
What i am trying to do is write sub query of this one which shows which tenants are due to pay within the next 7 days.
But the access query seems to ignore the criteria I'm putting in....in the next payment date criteria i have tried specifying >Now() + 7 or >Date() +7 but neither seem to work, it just shows up every record...
I have a large database filled with customer records. Some customers come one time. Other customers come 50 times at year. I want to find all customers that have records that are less than 30 days apart so I can ultimately see the types of products they buy. How do I write the query?
I attached a picture of a sample database. The 30 day (+/-) field doesn't exist but I would like the query results to build it.
I'm trying to breakdown a date into years, months, and days. Simple right?
The code I've been using for months returns a negative month if it happens to be the next month. Instead of returning 1 Year, 1 Month, 23 Days, it will instead return 1 Year, -1 Month, 23 Days.
My database keeps track of training for employees, some of which expires after a period of time, which is in the tables. I need to create a query that displays only the employees and the training that expires during the next 30 days. I have a query that displays the expiration date (this field uses DateAdd and adds the expiration term to the date the employee completed the training) I am trying to add a criteria to this field. I found <=Date()+30 in my searches but that displays all of the records from 12/14 and back. I have tried all kinds of versions of this (obviously, not the correct one) and either get all records or none. (Yes there are records in the database that fall within the the period I am trying to display - that is something that I have been known to forget)
Is it because I am using criteria in a field that is based on DateAdd or what would be the correct criteria for this?
I have 2 dates that I need to count between. Easy enough just use the datediff right? Nope cause it won't count just the 5 workdays. I researched and found that the "w" in the function doesn't work the way I need it to. I found lots of code to make a module that will do it for me and they all include having a holiday table. Right now I don't need a holiday table I just want the simple dates in between.
I have a query that uses two criteria from a user input form. On the form, the user would input a customers last name and use a dropdown list (based on a table 30,60,90,120,365 days) to select how many days previous they want to search. Unfortunately there is something that I'm over looking and can't figure out.
Let's say I have multiple records that match the following criteria: Last name "James", days since contracted all less than 30 days. For some reason when I put in "James" as the last name in my form and select "30" from the droplist, it only lists the most current one which is zero days. Even if I select "60" from the droplist, it still only shows the zero day contract.
If I go back and select "90" from the droplist is brings up 3 - 3 day old contracts and my 1 zero day old contract. If I select 120, it picks up another contract that is 4 days old. If I select 365 it picks up a couple more, but still not everything. Here is my SQL code.
Code: SELECT tblAllData.[F&I Manager], tblAllData.[Reviewing BOA], tblAllData.Date, tblAllData.[Stock#], tblAllData.[Deal Date], tblAllData.[Cust First Name], tblAllData.[Cust Last Name], Round(DateDiff("d",[deal date],Now()))/1 AS Days, tblAllData.[Bank Name],
I am building a report and need to know the coding in the query (or in the report) to achieve the following.
Currently, in my query - 3 fields that work fine:
AppDate - dates of set appointments (Appt)
MonthNo: DatePart("m",[App_Date]) - get Month value
YearNo: DatePart("yyyy",[App_Date]) - get Year value
What I need is : EXACT coding to get these counts to show in my report:
January 2013 12 appointment (there were a count of 12 appts in January) over 23 days (there were 23 days where appts were booked in January) of 31 days (total number of days in the month of January)
February 2013 18 appts (there were a count of 12 appts in February ) over 19 days (there were 23 days where appts were booked in January) of 28 days (total number of days in the month of February )
I have a query that records a status update, and the date it was made by an employee etc. The table has a secondary key related to ... lets say a project table.
E.g. Status Id; EmployeeID;ProjectsID;Status;Date
I want to calculate the average amount of days it takes for a status change occur.
I am building a database with Access 2013. The information contains data built from a workplace violence report form. I have to build a query to pick the data but must fall between two different years.The data range must be from 09/01 previous year (ex. 2012) and 08/31 current year (ex. 2013).
As the database collects more information, the year range will change but the other information will stay the same (ex 09/01/2013 to 08/31/2014).I do not want to change the query annually, just let it change the year automatically.