Subtracting 2 Dates And 2 Times From Seperate Boxes

Jul 6, 2007

Jus thought I'd offer this code to the forum as spent a long time finding a suitable solution..

SELECT DischargeTime.ID, [Arrival Times].ID, [Arrival Times].[A&EArrivalDate], [Arrival Times].[A&EArrivalTime], DischargeTime.[Date of outcome], DischargeTime.[Time of outcome], DateDiff("d",[A&EArrivalDate],[Date of outcome]) AS DateDifference, [Time of outcome]-[A&EArrivalTime] AS TimeDifference, IIf([DateDifference]>=1,([DateDifference]*(1/24)*576)+[TimeDifference]*(1/24)*576,([DateDifference]*(1/24)*576)+[TimeDifference]*24) AS hours3
FROM DischargeTime INNER JOIN [Arrival Times] ON DischargeTime.ID = [Arrival Times].ID;

Basically I had an admission date and in a seperate box an admission time and then I had a discharge date and discharge time again in seperate boxes. The information was spread over two tables hence the join. How I solved the problem was by gaining both the days difference between and then the difference in hours and then I created an iff function and played around with it till it worked. Dont really know how i got it working in the end but it does so hopefully this code will save some1 alot of time!

(I know that if id shown my dates as date/time in 1 box the problem would have been much easier solved, however I dont personally like displaying dates and times that way especially when you have inexperienced people entering data)

Find below a result from the query

DischargeTime.IDArrival Times.IDA&EArrivalDateA&EArrivalTimeDate of outcomeTime of outcomeDateDifferenceTimeDifferencehours3
1119/06/200715:0420/06/200712:00103:0420.93

View Replies


ADVERTISEMENT

Subtracting Two Times To Fill Out Textbox?

Jan 31, 2006

I have 2 time boxes with times in them. How do I get the 3rd textbox to display the difference between those times?

View 11 Replies View Related

Subtracting Dates From Adjacent Dates In Same Column

Sep 7, 2006

Hiya-

I have a database with 5000 entries, corresponding to about 10 entries for about 500 people. Each of the entries is dated, and I need to calculate the time intervals between each person's sequential entries in the table.

One way of doing this is to create another column that contains the date of the previous entry. I can then use DateDiff to subtract one date from the other and give me the difference in days.

This approach falls down if I then work with only a subset of the entries - I would have to re-enter the previous entry dates as the time intervals would have changed.

What I really need is a way of subtracting the date from the date in the cell directly above it. Will Access let me do this, or is there a better way?

Many thanks, Jules.

View 3 Replies View Related

Seperate Text Boxes From Labels

Jun 8, 2006

I am learning access on my own using MS Press step by step manual and it tells me to hold down the shift key while selecting the text boxes that are next to the labels, but when I do the labels get selected also . how do I disconnect the labels from the text boxes in order to insert space between the labels and the text boxes as it intructs me to in the book. I am able to select the labels separately, but it will not allow the text to be selected separately.

View 1 Replies View Related

Subtracting Dates, Getting Whole Months

Dec 12, 2005

I found the following code on this site in a search for a method to subtract two dates ie [Startdate] and [EndDate] and display the result as a whole number. ie 2, 6 etc. This code finds the difference but displays the results as 1 year 5 months 2 days, where I need the equivalent as 17.
Can this code be modified to produce the desired result and if so how would I go about it. Thanks for the help.

Option Compare Database
Option Explicit

Public Function getTimeElapsed(StartDate, Optional EndDate As Date) As String
On Error GoTo Err_Handler

If IsNull(StartDate) Then
getTimeElapsed = "No startdate"
Exit Function
End If

Dim YY As Integer
Dim MM As Integer
Dim DD As Long

' use current day if EndDate is not supplied,
' + 1 makes both days inclusive.
EndDate = IIf(EndDate = 0, Date, EndDate) + 1

MM = DateDiff("m", StartDate, EndDate)
DD = DateDiff("d", DateAdd("m", MM, StartDate), EndDate)

' recalculate if DD is negative.
If DD < 0 Then
MM = MM - 1
DD = DateDiff("d", DateAdd("m", MM, StartDate), EndDate)
End If

YY = MM 12 ' integer division.
MM = MM Mod 12 ' remainder.

getTimeElapsed = YY & IIf(YY < 2, " year ", " years ") & _
MM & IIf(MM < 2, " month ", " months ") & _
DD & IIf(DD < 2, " day", " days")
Exit Function

Err_Handler:
MsgBox Err.Description
Exit Function

End Function

View 1 Replies View Related

Subtracting Dates In Queries

Feb 1, 2013

My form consists of a textbox with a selected date. I have a combo box with integers 1-15. I have a table with 15 people and their birthdays.

I am trying to find the birthdays after a selected date by the integer selected in the combo box. For example, if I select 2/1/2013, and pick 7 in the combo box, the subform should show me people with birthdays 2/1 through 2/8.

I have a query with a datediff function. This is my query expression Expr1: DateDiff("d",[DateofBirth],[Forms]![Calendar]![Text1]) The criteria is <=[Forms]![Calendar]![Combo3].

It displays some data, but it's not consistent at all. I'm hoping to fix this without any SQL changes or form code. But if that's what I need, I'll do it.

I'm using access 2010, and I'm fairly new at it.

View 1 Replies View Related

Append Data From Unbound Combo Boxes To Seperate Table

Aug 4, 2007

I have a form setup that has 5 combo boxes where a user will select one item from each combo box. Each combo box is from a differant table. Once this is done I want to be able to append or update the results into a new table I created. My problem is I don't know how to submit the data from the combo boxes to the new table. Can anyone help me with this?

Thanks

View 11 Replies View Related

Adding And Subtracting Dates From Current Date

May 7, 2013

My first question is how to set a column to be the current date read by the computer.

Example: It will automatically say 5/8/2013 tomorrow without needing updating.

Question 2: How to add a number of days to the current date.

Example:

Add 7 days to the current date.

on 5/8/2013 it will read 5/15/2013, then automatically update to 5/16/2013 on 5/9.

View 1 Replies View Related

Comparing Multiple Dates And Times In A Query

Mar 8, 2007

Hi there,

I'm trying to 'rank' x5 categories that overlap. To determine the ranking i'm utilising date & time (if the dates are equal). I've managed to do this comparing x2 of the categories but struggling with the logic for x3,x4 & x5 categories

I have the data in separate tables by category date & time and in one large table.

Hoping someone can assist as my head is starting to hurt.

Thanks

View 4 Replies View Related

Queries :: Query Criteria Between Two Dates And Two Times

Sep 1, 2014

I have a table which list a load of items, one field is date and one field is time.I have a form with two date boxes and two time boxes, the idea is for the user to search between the two inputted dates and the two inputted times.This then runs a query for a report to be produced. The problem I having is getting the query to runs both criteria it returns nothing.here is the Where part of the current SQL.

WHERE (((tblIncident.IncDate) Between [Forms]![FRM_SearchMulti]![txtrepdate]
And [Forms]![FRM_SearchMulti]![TxtrepDateB]) AND ((tblIncident.IncTime) Between [Forms]![FRM_SearchMulti]![txtreptimea]
And [Forms]![FRM_SearchMulti]![txtreptimeb]))ORDER BY tblIncident.IncDate, tblIncident.IncTime;

View 7 Replies View Related

Queries :: Query Filter Out Data From A Table Between Times On 2 Dates

Jul 24, 2014

Running Access 2010 and developed this query to filter out data from a table between times on 2 dates (day before report run and day of report). Covers data from a shift that carries over to the next day.Trouble is, the PC i developed on still operates the query as expected. However, on the PC the database resides (not networked just stored) and operates, the query brings up no data at all unless I remove the Time filtering.

This PC used to operate correctly up until early this year (about 18 months operated correctly) when the PC was replaced due to failure. Access version is the same and I am at wits end to what the cause is. Here is what my query looks like:

Quote:

SELECT Breakdowns.BreakdownDate, Breakdowns.Time, Breakdowns.Shift, Breakdowns.Downtime, Breakdowns.Equipment, Breakdowns.Conveyor, Breakdowns.Fault, Breakdowns.Stopper, Breakdowns.Gate, Breakdowns.Dolly, Breakdowns.Carrier, Breakdowns.FaultType, Breakdowns.Comments, Breakdowns.Tradesman
FROM Breakdowns
WHERE (((Breakdowns.BreakdownDate)=Date()) AND ((Breakdowns.Time) Between #00:00:00# And #6:29:00#) AND ((Breakdowns.Shift)="Night")) OR (((Breakdowns.BreakdownDate)=Date()-1) AND ((Breakdowns.Time) Between #22:30:00# And #23:59:00#) AND ((Breakdowns.Shift)="Night"));

View 14 Replies View Related

Dates And Tick Boxes In A Form

Jun 2, 2006

Hey,

I hope this is the right place to be posting this...

I've set up a database about unemployed people and it has a field called "Start Date of Employment", where a date is manually entered by the user.

Further down, there are two tick boxes - one called "13 weeks", and one called "26 weeks".

Now, what I'd like to happen, is that the database looks at the "Start Date of Employment", and then if 13 weeks have passed, it puts a tick in the 13 weeks box. Then when 26 weeks have passed, it puts a tick in that box also.

I'm assuming that this is possible, but I have no idea how.

Can anybody help?

Thanks

Dan

View 8 Replies View Related

Compare Dates In 2 Unbound Text Boxes

Feb 20, 2015

On a form I'm asking a user to enter dates in 2 different textboxes, say, [text1] and [text2], both formatted to short date. In a third textbox [text3] I need to see the date of the greater of the two, and in a fourth [text4] I need to see the date of [text3] if it falls on a Monday through Friday, or the date of the previous Friday if [text3] falls on Saturday, and the date of the following Monday if [text3] falls on a Sunday.

...a couple quick examples;

If text1 = 2/20/2015 and text2 = 2/27/2015, text3 should evaluate to 2/27/2015, and text4 should evaluate to 2/27/2015
or
If text1 = 2/20/2015 and text2 = 2/28/2015, text3 should evaluate to 2/28/2015, and text4 should evaluate to 2/27/2015

My attempts to compare text1 and text2 revolve around an IIF but result in an error...

Entering this into [text3]... IIF([text1]>[text2], [text1], [text2])

results in "#Name?" error, which I interpret as meaning the date from the source cannot be pulled into the formula.In attempt to check the day of week, I used =Weekday([text3],1) which results in a number. I haven't been able to do an IIF on it as it errors with #Name? again.

View 3 Replies View Related

Attaching Dates To Drop Down Check Boxes

Feb 10, 2014

I want to be able to attach a date field to a dropdown check box. For example, say I have a client who we submit multiple deliverables to on different dates. I want to be able to check the deliverables submittted and add the date for that deliverable (each deliverable has a different date). image which is how the drop down is currently set up.

View 3 Replies View Related

Seperate One Column Into Two

Oct 20, 2006

Hi,

I was wondering if there was a query to run that would seperate a field in a column into to.

The Current Field is Prec and the entries all are numeric numbers followed by a dash and another numeric number i.e.
9700064-0
7600049-0
Another 7 digits-one digit
I would like the first 7 in a column called prec1 and the one after the dash in a column called grp

Thanks in advance

View 2 Replies View Related

2 Seperate Sub Forms On One Form

May 24, 2005

Is it possible to have 2 sepaerate sub forms, with different source objects on a single form. I thought it was, but every time I save the main overall form, the source object of the second subform changes to the source object of the first.

Can anyone shed any light on this?

View 3 Replies View Related

Seperate Password For One Table??

Mar 3, 2008

Hey all,
For securing a database, is it possible to set a certain password for users to view just one table? like i've lots of tables in my d.b that i plan to use a workgroup file for different users to view it, but there's one that i only want certain people to access...can this be done at all??

Cheers,
Sue.

View 2 Replies View Related

Seperate A Imported Field From Outlook

Apr 1, 2008

Hi

I have imported data from Outlook. The field I am interested in is the
'Subject' Field. This contains 3 effective segments,
1 employee name
2 description
3 job and sub job number

example of text in field is

M.Heywood Completed Job No.1708 8
N.Curry Completed Job No.1477

I wish to move the employee name into another field and also the job and sub
job number. I have tried the following Right() Function but it is not quite
working as I want

Right$([Subject],InStr([Subject],"Completed Job No.")-1)

For the records above the results are as follows

No.1708 8
No.1477

What I really want is to only get the text after the .

Any help please as this is my first time with this function

Thanks

Richard

View 1 Replies View Related

Fields Generated From A Seperate Table?

Feb 24, 2005

Hello,

I'm making a table with a Yes/No choice many fields which represent subscriptions.

The problem is that the subscriptions available will need to be changed fairly often - will this mean the table and the form associated with it need to be redesigned?

If so, I don't know how to make fields that change depending on a different table.

If this can't be done, I'd be interested to find out how else I could go about this.

Thanks for any help you guys can offer.

View 2 Replies View Related

Link Two Seperate Database Tables

Mar 9, 2005

Is it possible to create a database and link this to a form and another database? What i want to do is link a network database with a local database on a client machine?

View 3 Replies View Related

Import A Csv File And Seperate Bad Data

Jun 15, 2005

I want to import a csv file and store the good data (which matches input masks, validation etc) into one table, and all the bad data which is rejected into another table.

I've read a bit about an import error table, and although I do get errors when importing the csv file, no such table is generated.

Many thanks

Cc

View 1 Replies View Related

Seperate Date And Time Fields

Jun 12, 2006

I'm working with a linked table that has a seperate field for the date, and a seperate field for the time (which show in the linked table as '11/30/1899 9:46:00 AM'). I need to calculate the time difference between 2 entries.

How can I merge the 2 fields into a combined date/time field for my calculations?

Thanks,

Sup

View 4 Replies View Related

SubForm Requery From Seperate Form

Aug 11, 2005

Hi. Having a bit of a problem getting a subform to requery/refresh after running a query from a seperate form. The seperate form is acting as a 'search form' and running query qSearch.

I've tried various things (requery the form, subform etc) but here is the code I'm currently using:

Private Sub RunqSearch_Click()
DoCmd.OpenForm "Papers"
Forms.Papers.RecordSource = "qSearch"
Forms.Papers!Authors.Form.RecordSource = "qSearch"
Forms.Papers!Authors.Form!AuthorName.ControlSource = "qSearch.AuthorName"
Forms.Papers!Authors.Form.Requery
Forms.Papers.Requery
DoCmd.Close acForm, Me.Name
End Sub

The main form is requerying fine, but the subform isn't. Any help would be appreciated. Thanks

View 4 Replies View Related

Recall - Search Seperate Table

Nov 17, 2004

I want to be able to find the last value entered into a table from a form that is not based on that table. How do I go about this?

What I am trying to do is produce a 'purchase order number system' that adds 1 onto the previous number, but this purchase order can be generated on many forms and for many reasons across the database. I do not want to use autonumber.

Cheers,
Recall.

View 1 Replies View Related

Sharing Variables Between Seperate Reports

Nov 29, 2004

Hi ya,

Still working on a products catalog. I am creating this by printing a couple of separate reports, each with its own category.

At the end of a report A I store a value (number of pages) into a variable "NumPage", defined in Visual Basic. I have made this variable public and also the sub in which it is altered (report_close()) is public.

Now I should have stored the number of pages of report A in NumPage, enabling me to start report B with the right page. However in the public sub (on_open()) of report B I am not able to display the value of NumPages (just using a messagebox to check if it works).

Does anyone know whether it is possible, and if so in which way, to pass a variable created in a module of report A to report B?

Cheers,

Thomas

View 1 Replies View Related

Seperate Database Records In Divs?

Feb 8, 2005

I am trying to create a page that can display 4 different records from a database, each one in a different div container, for a news page.

I have an access database containing news records - headline, news and date. Each record also has its own auto-numbered ID.

So far I have managed to get the asp page to display all of the records in a list by using:

recordset.movenext
Loop

and I have managed to get just 1 displayed by using:

SQL = "SELECT * FROM tblNews WHERE ID=1" and changing the ID number.

But I can't seem to find a way to display each in a different div container on the same page. Can anyone help please? I think this is really obvious but I just can't see it!

Thanks.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved