Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding year and searching in query

Status
Not open for further replies.

MattCrane

Technical User
Apr 21, 2004
4
GB
Alright this is probably a bit of a novice question to ask but im having problems with it so im hoping someone else can help. What i need is to craete a query that looks at a date field in a table adds a year to it and will then display it if its within the search parameters.
e.g. the first date is 12/03/2004 so when the query is run and the two imbetween dates are set e.g. 1/03/2005 - 31/03/2005 the details for the earlier value will be shown.
Ive got the coding working for date add in a seperate field were its looking up the 'date of transactrion' which is the one that needs a year adeed to it. But when you put the search criteria in criteria it simply shows allt he values in the table (althopugh the year is added on). Any ideas on what I should do? Any help would be appreciated.
 
Hi,

Code:
Between [MyDate] and DateSerial(year([MyDate])+1, month([MyDate]), day([MyDate]))


Skip,

[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue]


 
Thanks for posting but ive already more or less got the imbetween date comamnds working. Perhaps I should explain it a bit more. in the query at the moment ther are 2 important fields 'date of transaction' and 'warranty due' at the moment in the field value for warrant due is 'warranty due: DateAdd("y",[Date of transaction],365)' this works fine and dispalys the date a year later but if you put your code in the criteria or other codes ive tried it will simply dispalya ll the records. An idaes how to sort it out?
 
Even if the paramaters are type in a non ambiguous manner, like this ?
#2005-03-01#

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top