DateAdd / Comparison A97 Problem

Feb 8, 2008

I'm running a query to find records over one year old. When I use Date()-"365" or DateAdd (365 days, 12 months, 4 quarters, or 1 year) the records from one year ago today come up just like they are suppose to. The problem comes in when I put the comparison operator out front.

If I put < in front of either Date() or DateAdd minus one year, I get all records from yesterday and earlier as if it is ignoring the year and only looking at the month and day. If I put > in front, I get today's records.

Date() and DateAdd by themselves are working as advertised. Things only get weird when I put < or > out front.

What am I doing wrong?

Thanks,
Forrest

View Replies


ADVERTISEMENT

Need Help With DateAdd()

Sep 14, 2007

I have a table that includes a client account number, revenue, and a Date in the format YYYYMM. I would like to create a query that sums the revenue for a client where the date is six months prior to today.

Thanks in advance

View 2 Replies View Related

DateAdd

Oct 13, 2004

I think I have a simple problem: In a database table I've made there is a field called <date> (in the date&time format), in the table there is another date field, which should contain a date always 6 months later than the <date> field. For conveniance, I created a form to fill in all other fields in the table, including the <date> field. Succesfully I tried to calculate the 6-months-ahead-date in the form with DateAdd, but I tried everything I could (which is not so much) to store this result in the table, since I need it there for a few reports I generate.
Who can help me to solve this problem??

View 2 Replies View Related

Table Comparison

Feb 26, 2006

Is there a way to look at two tables to compare records and add missing records from table to the other?

Thanks!
Terry

View 3 Replies View Related

Comparison Operators.

Apr 27, 2006

I'm having difficulty coming up with a way to exlcuded a group of dates from my Query. I am trying to have a set of dates come up without the dates, between 7/1/2006 and 7/31/2006.

I've tried <> Between #7/1/2006# And #7/31/2006#, and a few others with quotes and such. Any help would be greatly appreciated.

View 1 Replies View Related

Date Comparison

Jun 13, 2005

Hey all,

I've got to show records from a table that are 45 days old or newer.. im not quite sure how to do this in SQL ...

Select field from table where date > (todaysdate-45).. as you can see..clueless lol any help is _greatly_ appreciated

View 3 Replies View Related

Dateadd Issue

Feb 18, 2007

Hi,

This problem has to be easy but I can't make it work. The attached database has a table name BOL information. Inside that table are the two columns I'm having an issue with. I want ETA Date to be 30 days after BOL date. I have been screwing around with the Dateadd function and can't get it to work. I have been putting the following in the default value of ETA date:

Dateadd("d",30,[BOL Date])

The error message I have been getting is The database engine does not recognize either the field 'BOL Date' in a validation expression, or the default value in the table 'BOL information'.

What am I doing wrong? Should I not be putting the formula in the default value? Should I use another way to get this calculation? Your thoughts are most welcome.

Thanks in advance.

Eddie.

View 2 Replies View Related

Question On Using DateAdd....

Jan 3, 2008

I have a table that tracks the inspection dates for various structures. I have a field called InspectionDate in the form of 99/99/9999. Another field called Interval which can range from 6 months to 48 months. I have always gone in to edit another field called InspectionDueDate. Is there a way to have the InspectionDueDate field automatically be filled based on the other 2 fields? Does this make any sense? Thanks in advance.

View 4 Replies View Related

DateAdd Weirdness

Jun 28, 2005

Howdy all,

I've written a simple little function using the DateAdd system function which i call from query. Here's the logic

If (PassFail = "Pass") Then
IsNull (FirstRepairDueDate)
Else
FirstRepairDueDate = DateAdd("d", 5, InspectionDate)
End If

basically if the PassFail argument is "Pass" I would like the function to not display anything, however i'm not sure what to do because my function returns a data type of Date, which it defaults to 12:00:00 AM using the above logic.

Any ideas?

Many thanks

View 5 Replies View Related

DateAdd Problem

Oct 23, 2005

I'm VERY new at using VBA although I have been programming for many years.

I have a requirement that involves creating a new version of a record and setting the expiry date of the current version to one day less than the effective date of the new version.

Regardless of what I try, the new expiry date that gets set is always 12/30/1899.

I suspect there is something very elementary that I'm missing, but haven't been able to figure out what it might be. Perhaps I need to apply a function to the setExpiryDate variable?

Any suggestions would be appreciated. Here is the current version of the code I'm working with:

Private Sub createNewVersion_Click()

Dim strUpdate As String
Dim intervalType As String
Dim adjustment As Integer
Dim setExpiryDate As Date
Dim newEffDate As Date

intervalType = "d"
adjustment = -1
newEffDate = Forms!fCreateDomainVersion!NewEffectiveDate
setExpiryDate = DateAdd("d", -1, newEffDate)

strUpdate = "UPDATE tDomain " & _
"SET ExpiryDate = " & setExpiryDate & _
" WHERE DomainName = Forms!fCreateDomainVersion!DomainName AND " & _
"EffectiveDate = Forms!fCreateDomainVersion!EffectiveDate;"

DoCmd.RunSQL strUpdate

End Sub

View 1 Replies View Related

DateAdd Question

Nov 27, 2005

Hello

I'm very new at this - just found out about the DateAdd function today trying to solve my problem, so that you know who you're dealing with.

Let's say Im operating a video rental shop, and want to calculate a DateDue (=when videos need to be returned) based on DateRented and number of videos rented..

DateAdd ("d", 5, [DateRented]) would be appropriate for 5 videos rented at once.

I want to replace 5 here with a number of videos rented, and this number (TAPECOUNT below) is also calculated in a query using count function (to count the number of videos associated with each rental)

Preferably I would end up with a single query consisting of 4 columns:
RENTAL_ID, TAPECOUNT, DATERENTED, DATEDUE, of which both 2nd and 4th column would be calculated, 2nd in combination with 3rd serving as input for 4th.

Can it be done like this and how? Would I need to store TAPECOUNT value first? Is DateAdd even a proper function for my task? I'm open to all suggestions, just keep in mind I'm a newbie.

View 4 Replies View Related

DateAdd + Days

Jun 19, 2006

I have a table that has several fields however the ones I'm working with are Date, Letter, RollOff.

Date being the date the record was entered example 6/1/2006

Letter can be letter codes simply a,b,c,d,e etc

RollOff is 1 year from the Date the record was entered.

I've searched though several pages of dateadd info but haven't ran across an exact similar situation so far.

Getting the RollOff is no problem, simply DateAdd("yyyy",1, [Date]). However what I'm attempting to do is I need to add a certain amount of days to the calc between the date entered and the 1 year rolloff that match the Letter of "B".

Each record entered will only have 1 Letter and each entry is only for 1 day.

I'm thinking I will need a second query that will gather the sum of "B" codes to determine the amount of days needed to add to my DateAdd calc.

sample layout would be.

Date Letter RollOff
6/1/2006 A DateAdd("yyyy", 1, [Date]) + 3 days of B Codes for 6/2,3,4
6/2/2006 B
6/3/2006 B
6/4/2006 B
6/5/2006 C

Since 6/1/2006 RollOff is 1 year 6/1/2007 however since there was "B" enteries between the time the record was entered and the RollOff date the amount of days needed to be added so the RollOff would actually be 6/4/2007.

Any help would be appreciated.

View 5 Replies View Related

DateAdd Problem

Jan 13, 2007

I have table with two fields, [StartTime] and [FinishingTime].

On an unbound form (frmGameBooking), the [StartTime] is entered and also (via a combo box) the number of hours i.e. 1 hour, 2 hours, etc.

On pressing a command button the form, an update query is run to populate the [FinishingTime]. If the [StartTime] is chosen to be say 11:00 AM and the number os hours is selected to be say 2 hours, the update query places the value 13:00 for the [FinishingTime]. However if I choose a [StartTime] of say 23:30 PM and select 1 hour, the update query doesn't update the [FinishingTime].

Can anyone help. Here's the SQL code of the update query:-

UPDATE tblTables SET tblTables.BookingTime = Forms!frmGameBooking!TimeValue, tblTables.FinishingTime = Right(DateAdd("s",3600*CInt(Left(Forms!frmGameBooking!No_of_Hours,1 )),Forms!frmGameBooking!TimeValue),8);

The Right function is used to obtain the time portion.

View 8 Replies View Related

DateAdd Syntax

Feb 22, 2005

Hi

I have a combo box on my form. I wish to set the value of a text box on lost focus of the combo to be the value of the combo cbxDateFrom +6 months

The code I am using is

Private Sub cbxDateFrom_LostFocus()
cbxDateTo.Value = [DateAdd("mmmm", 6, me.cbxDateFrom.Value)]
End Sub

But it does not appear to work in any variant I have tried. If it is easier to do it in properties or event builder I don't mind that, I just need the right syntax

Regards

View 5 Replies View Related

DateAdd Function

Sep 24, 2004

I am using the following to populate text boxes that are functioning as labels in my report. I am getting an error: #NAME. Do you know what's wrong with this code??

=DateAdd("d",-1,Forms!frmDates!txtEnd)

This prompts me for txtEnd. When I put in the date (which is a parameter from my SQL cross tab query, the values in the report WORK, but the label doesn't. Any ideas?

View 1 Replies View Related

DateAdd Functions

Mar 10, 2005

I enter this statement on my control source in a text box
of a report for a date field.

=DateAdd("d",1,[startdate]

I get error when I preview the report. I trying to add 1 day
to the date.

Thanks in Advance

View 2 Replies View Related

Text To Date Comparison

Jan 24, 2007

Hi all- I'm creating an update query.I have a field [dateLastEdit] that is stored as text, I have to compare it to a date entered on a form by user [date_from] (I need to select all dates greater than this) but I'm running into problems:when I use date_from in text or date format and compare it to dateLastEdit in text format the comparison is made in numeric order(so 12/02/2006 is selected as well as 12/02/2005 when date_from is 12/01/2006)SELECT PTSData.LastEditDateFROM PTSDataWHERE (((PTSData.LastEditDate)>=[Forms]![chMgmt_frm]![date_from]));when I use date_from in date format and compare it to dateLastEdit converted to date format I get "expression typed incorrectly or it is too complex to be evaluated" msg.SELECT DateValue([LastEditDate]) AS Expr1FROM PTSDataWHERE (((DateValue([LastEditDate]))>=[Forms]![chMgmt_frm]![date_from]));[LastEditDate]'s format is always mm/dd/yyyy hh:mm:ss, but as text, not date data type.I've tried CDate with same results, isolating it in its own query to test it, using hardwired dates as criteria, but no joy, am I missing something obvious?forgot to add- I've used all the above with left also to select only date portion with same results

View 5 Replies View Related

Values Comparison Query

Nov 20, 2007

I really have looked everywhere

I have 2 fields and I want a query to pull out the records with a lower or equal to quantity value than the stock.

ReorderValue
3
5

Quantity
2
6

As you can see it shuold pick out the top record because its lower, I just need a way of telling it to look at each records Reorder Value

View 8 Replies View Related

Complex Query And Comparison

Aug 9, 2005

I have a scheduling database that my company uses to manage our customers deliveries. We would like to make this database more intelligent by adding some logic and I am not quite sure how to proceed.

On the form frmDelivery, the user inputs all the header information for the delivery, in the subform subfrmLotInfo, they input the houses that will be delivered, the delivery date, and some other miscellaneous information.

When the user inputs the delivery date, the system should count back a number of days based on other criteria and set a build date (when we should start building the cabinets, typically 5 days before the delivery date). Then I need the database to run a query against this date and determine how many boxes we have scheduled to be built already on that day, if it exceed a certain number than I need to it to search an available date close to that date that has not exceeded our production capacity and schedule the lot for that date.

This needs to happen as well if the user changes the delivery date at a later time. Our customers change delivery dates constantly. This will help us schedule our manufacturing plant better and reduce the possiblity of scheduling more than we can actually accomodate.

I have a table tblPrdCapacity that holds how many boxes we can build on a given day. It hold Date, PrdCap (number of boxes). In the subfrmLotInfo, the field BoxesBuilt tells how many boxes will be built for that Lot.

Any info would be greatly appreciated!! I have been tasked to accomplish this as soon as possible.

Thank you!!!

View 3 Replies View Related

Dateadd (Validation Rule)

Jan 12, 2005

Hi,

I have a field "dimissioni" data/time field and I' m trying validatation rule Dateadd ("d"; [giorni_somma] ; [data_ingresso ]) where "giorni_somma" is a field number integer and data_ingresso is other field Date/Time; my problem is access does't find field "data_ingresso" and "giorni_somma". If I use Dateadd ("d";"2";Now()) access works fine and validation rule is ok.
I hope in help.
Best Regards.

Delfo

View 1 Replies View Related

Complex DateAdd Function

Aug 4, 2006

Hi All,

i have a slight problem i have a access table which has the following fields:

Name
Photocard ID
Purchase Date
Photo
Cashsaver Zone
Valid From
Period of Validation
Expiry

the period of validation field has a lookup to another table with the folwing values: 28 Days, 3 Months, 6 Months and Annual.

the valid from date is entered manually.

basically (maybe not uite the right word!) i need the the expiry field to automatically insert the correct expiry date by looking in the valid from date and adding the correct amount of time onto it according to what is selected in the period of validation field.

example:
Valid from date is 01/01/2006
Period of validation is 6 Months
Expiry date should be 01/06/2006 (01/01/2006 + 6 Months)

i came up with the following formula although i know its not really correct and some of the words arent functions at all just to show what is should be based on:

WHERE Period of validation <= DataValue ("28 Days") then DateAdd("d",28, Period of validation)
WHERE Period of validation <= DataValue ("3 Months") then DateAdd("m",3, Period of validation)
WHERE Period of validation <= DataValue ("6 Months") then DateAdd("m",6, Period of validation)
WHERE Period of validation <= DataValue ("Annual") then DateAdd("m",12, Period of validation)

also i am unsure into what box to type this into?

i would greatly apperciate some help

Spindlemania

View 6 Replies View Related

DateAdd() In WHERE Clause Not Working?

Aug 1, 2005

This is driving me crazy! What am I missing?

Here's my query:

SELECT tblRelease.ID, tblRelease.Application, tblRelease.Date, DateAdd("d",tblRelease.DateVariance,tblRelease.Date) AS ToDate, tblRelease.Time, tblRelease.Description
FROM tblRelease
WHERE (DateAdd("d",tblRelease.DateVariance,tblRelease.Date)>=[Enter Effective Date])
ORDER BY tblRelease.Application, tblRelease.Date;

I've chopped out a few fields to make it a bit smaller and easier to read.

The problem is that whilst the DateAdd() in the SELECT clause produces exactly the date that I want, the DateAdd() in the WHERE clause does not seem to work. I always get all records no matter what date I enter for [Enter Effective Date]. If I change the WHERE clause to

WHERE (tblRelease.Date>=[Enter Effective Date])

then everything works perfectly and I get different numbers of records depending on the date I enter.

I am entering the date in the form 01/08/2005 and this works for the second variation just fine. It's dd/mm/yyyy in case that's important (my local default).

Anybody see my problem?

View 1 Replies View Related

Simple Dateadd Query

Sep 12, 2005

Hi

Sorry if sometihng similar has been posted.

But all I want to do is get this to return data that is a month from now

Gate: IIf(Format([7 PDB],"mmyy")=Format(Date(),"mmyy"),"Move to Delivery")

Any help appreciated

PK

View 1 Replies View Related

Dateadd Not Calculating Properly??

Nov 18, 2005

Hi,

When i use this

between #01/07/2005# and #01/09/2005#


It all works ok and pull outs what i need.

But when i do

between #01/07/2005# and DateAdd("m",3,#01/07/2005#)


I have also tried it without the # and with 2 instead of 3.

No luck :(

Any ideas?

Thanks
k0r54

View 11 Replies View Related

Ac97 Replacement For DateAdd()

Mar 15, 2006

Can anyone suggest a work around for the DateAdd() function. I have Access 97 and this function is not available.

View 3 Replies View Related

Dateadd Query Problem

Sep 2, 2007

Hi all,

I am trying to create a query that will calculate the date for a follow up appointment based on a dateadd function which uses a starting date and an interval (both held in a table) and then only display certain of the results based on a parameter (another date) defined when the query is run. The SQL statement I have used is as follows;

SELECT Schedule.[Pt Name], Schedule.Regime, Schedule.[Recall Interval], DateAdd("d",[Recall Interval],[Appointment Date]) AS [Next Appointment]
FROM Schedule
WHERE (((DateAdd("d",[Recall Interval],[Appointment Date]))=[Enter Date]));

However when I run the query i get an error message "This expression is typed incorrectly, or it is too complex to be evaluated." The dateadd function works fine without the parameter query so I take it that this means access doesn't like working out a date and then filtering the results according to a parameter in the same query. I am clearly going about this in the wrong way so can anyone suggest a better way of achieving the same outcome.

Thanks.

View 14 Replies View Related







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