You are on page 1of 17
Criteria >25 and <50 DateDiff Cyyyy", [BirthDate], DateQ) > 30 Is Null Description This criterion applies to a Number field, such as Price or those records where the Price or UnitsInStock field conte and less than 50. This criterion applies to a Date/Time field, such as BirthD number of years between a person's birthdate and 30 are included in the query result. This criterion can be applied to any type of field to show is null. UnitsInStock. It includes only ins a value greater than 25 ate. Only records where the today’s date is greater than /records where the field value City = “Chicago” AND BirthDats < Datefdd (" yyy “, 40, Da cry iy lt [iene Geta oo Simos Es sen] a cites -eniago: (3) bated yay. 400s) 1. The City and BirthDate fields include criteria 2. Only records where the value of the City field ie Chicago will satisfy this criterion, 3. Only records of those who are at least 40 years old will satisfy this criterion, 4. Only records that mestboth criteria wll be included in the result \Whatif you want only one of these conditions to be met? In ather words, if you have alternate criteria, how do youenter them? IF you have alternate criteria or two sets of independent criteria where itis sufficient to satisfy one set, you use both the Griteria and the or rows.in the design grid wD oy fis |iane Fisnane aay ao Te |exsnas — leas CD ycoaesast ODD 41. The City criterion is specified in the Criteria row. 2. The BirthDate criterion is specified in the ar row Criteris specified in the crite and errows are combined using the OR operator, as shown below: City = "Chicago" OR BirthDate < DateAdd (“yyy *, -40, Dated) Ifyou need to specify mere alternatives, use the rave below the er row To Include record that Exacly match value, such 2s china [bo net match aval, such 2s Masco begin wth the spectied string, such au bo rot begin swith the speciied sing, such xu Contain the species string. such ores De ret contain the speaied string. such 6 Korea Use this erterion “chinat Mot Mecca" Like U Not ike Ut Like "kare ot Uke “Korea” Query result Relurns records where the CountnyRegion fed is se te Chins Aeturne records where the CourtyRegian tells set toa courtsyegion other tan Mesica Returns records fr ll courtriesyregions whose nares start with “Ur sud a6 UK. USA, and so on, NoteWhen used ivan expression the ats (9 represents ay ng of characte — is ea called swldcad characte For lio such thaacter, ee he ale Accezewilscersenarsce eres, Returns records for ll courtries/regions whose nares start with 2 diaracer other than U Returns records fo all courtris/regions that contain he sbing| Kore Returns records fr all courtries/regians trate not cortain the string "Korea" Enel wth the pected string, such (0 nor ene with the spectied steng, such contain sll or missing? values De not sontain nl values contain zero length strings eo not contain 2270" length stengs contains nl values or 2ero-iength stongs Is no: empty or blank Uke “inet hot Lice “na ts tl te Mot + (3 paic oF quaress hot" OF Nl te Mot null Ard Ho Retums records for all ccunbsisjregions whose names end in "ina such a8 Chia and argentina Rensms record for all counries/regions that do nat end ina’ uch a5 China and Argentina Rerums recards where there isn value the fe ets records where the value ic not missing inthe fil Renin records where the field setto a blak faut net ld value, For example, records of sales made to another department might contain 3 blank yalue inthe CourtiyRegi on file, Retutrs records where the CountyRegion fel has a nor blanc wae, Renin records where there is ether na value the tea, or the Fiellis set a blank value Returrs records where the CountryRegion felé has a nonblank non-null value. Follow a >= "Mexico valve, such as Mexico, when sortedin alphabetical order Fall withine Like "A-D]Y specific range, such as A through D Matchoneof "USA" Or "UK" ‘two values, such as USA orUK Contain one of the values inalistoF values Contain Rightd{CountryRegion), certain yey characters at a specific position in the field value Returns records of al countries/regions, beginning with Mexica and continuing thraugh the end of the alphabet Retutns records for countries/regions whose names start with the letters "A" through "D Returne records for USA and UK. Returns records for all countries/regions specified in the list Returns records for all countries/regions where the last letter is, y Satisfy length requirements Matcha specific pattern Lend{CountyRegionl) >10 Like “Chi?” Retuins records for countries/regions whose name is more than 10 characters long, Returns records for countries/regions, such as China and Chile, ‘whose names are five charecters lang and the first three characters are "Chi Note: The dvaracters and, when used in an expression represent a single craracter — these are ako called wildcard characters, The character = Gnnot be used in the same expression with the? character: nor can it De Uses n an expression withthe *wilearl craracter, You may use the vuldcard characizr in an expression that also contains the % wiklcare characte, Criteria far Number, Currency, and AutoNumber fields “he felowing examples ae forthe Unitrce film a query that based on a table that stores produls information The ererion is spectie in the Criteria re of he fle inte query design gi (er 3 rete ‘Teincludle Ueethle Quory Racult records crit that rion Eady 100 —_—Retumnsrecards where the unt price ofthe products $100, match 2 value, such 2 100 Denot Not Returns records where the unit arice ofthe produ is not 1000, match 2 7000 value, such 36 1000 contain < 100 value 100 smaller than a vas, such 25 100 Containa >93.99, value 9 99 larger than a value, such 35 93.90 contain 206r25 one of the two ves, such 25 20 or 25 Contsina 249.99 vali that ane faliswitn 9 <95.99 range of -oF volues Between Sand 100 contain <59 ar value that > 100 falls outside range Retum records viere the unit price i ess than $100 (< 100}, The secare lemression ¢<=100)dlsplays records here she unt price i ess than equal to $100, Fetus records where the uit price fs greeter than $99.59 98.9), The second ‘exgression displays records where tie unit rice is greater tian or equal to $93.90, Returns records were the uit price either $20 or $25, Relurns records where the unit price is beteeen (out not including) $83.99 are $33.00 Return records viere the unit price isnot behueen $50 and $100 contain one ot many pectic values Cntain = vl that end vith the pected digits contain ral al ler missing) values contain rrr values nen, 25.20 ee nape te oul ts Not sul Returns records where the unt pice is ether $29, $25, or $30 Returns records where te unt ance ends with “4.98 such as $439, $1.98, $2483, and 50 on Note:The characte "and, when used nan expression represen any mute of choraetes thes me 0 elle ulead characters The chaacterskexonot te uted in the ame espemion with the’ character, norcan &bewiedinanexpresion uth the? alles characte You may use the wil at character % in an expression that abo Conesine Heard characte, Returns records where ro value ic entered in the UntPrice fl Returns records where the value is mat nssng in the Unie fle Criteria for Date/Time fields The flleing examples are forte OrderDate len 2 query based on a lable that sores Orders Informaban, The oitenan i species nthe Criteria row ef the Fell nthe query esi gr ‘To include records Use this criterion Query result that fact match a value, #2/2)200«6# Returns records of transactions tht took such a5 2/2/2008 place on Feb 2 2006 Remember to surround dave values vith the ® character so that Access can distnguish between late values andl txt etre Donat match a value, Not 2/2/2068 Returns records of transactions that took such as 2/2/2008 place an a day ether than Feb 2, 2006 Contain values that < 2/2/2006 Returns records of transactions that took falluetare s cerain place before Feb 2, 2006, date such 95 pea ‘To view transadtions that took place on for before this date, use the «= operator instene ofthe < operator Contain values that fall ater a cerain dale such as 2/2/2008 Contain values that falluitnin a date range Contain values that fall ouskle 2 range Contain one of tw values, such a5 2/0/2006 ar 27372006 Contain one of many values Contain date that falls in a speciic month (respective of yes, such a= December Contain late that fallin 3 speci quarter drrespectve af year such as the sist quar > meyeqe00e 2/2/2006 and = operator Ineized ofthe > operaion Returns records where the tensions tao place benueen Fee 2, 2006 and Fe 4, 2008 Sou can aso use the Between onerstor ro fiter for 2 range of values, incueing tie end aoits For exzmpe, Beween #82 /2/2006# ancl #2)4/2006 isthe same 2/2/2008 ane <=92/8/2008 Returns records where the transactions took place before Feb 2, 2006 or ater Feb 4, 2006, Returns records of tancaction: that took place on either Fed 2, 2006 er Feb 3, 2006 Returns records where the trensacions ao place on Fe 1, 2005, March 1, 2006, or April 1, 2006 Returns records where the transactions took place in December of ay year Returns records where te trnsacions took pce the frst quarter of any year Contain todays date Contain yesterday's date Contain tomorrow's as {Contain dace that fll during the eurent wees ‘contain dave: that fll luring the previous wees {Contain dares that fll during the folowing wees ‘contain a date that Fel curing the last 7 aye contain a date that belongs tothe arrest mont tea Dteo-t Dateo + 1 Doteparc’ |salesbate Dateparc", Dated) an Yeare [SalesDatel = YearDatep) ‘eartsalesbatep $3 + DateParicvn’ [SalesDate) = ‘year{Dateoy” 53+ DateParu’ Date) - 1 ‘earsalesbatep $3 4DareFart var, IsalesDateh = vearateos* S8+DaleP aria", Date) 1 Between Dated and Dateo-é ‘year(SalesDate) = Yearow0) And Monthgselespatep = MenthoNowd) Returns record of transactions that took place onthe current day. today’s date is 2/2/2006, you see recorels where the ‘reer Felis set 0 Fe 2, 2008 Returns ecards of transactions that tank place the day aefore the currert cay. f today’s date is 2/2/2006, you see recorels for Fes 7, 2006 Returns record of transactions that ook place the day after the current day. f today's date is 2/2/2008, you See recorls for Fé 3, 2006 tums records of transactions that took place during the curent week, A week starts on Sunday endl ends on Salurcay. Returns record of transactions that tok place during the last week A week stars fen Sunelay andl ends an Saturn tums records of transactions that vl take place next week Aweek starts on Sunday and ends en Sturdy. Return: record of transactions that ook place during the last 7 days. todays late is 2/2/2006, you see recards for the Perio! Jan 24, 2008 through Feb 2, 2006 Reus recards forte currant menth. today's date is 2/2/2008, you see recorcls for Feo 2006 Contain a late that belongs tothe previous month ‘contain a date that belongs tothe next month ‘contain a date that fell during the last 20 cer st days Contain a date that belongs tothe ‘urent quarter Contain a date that belongs tothe previous quarter ‘contain a date that belongs tothe next cuarter Contain a date that falls curing he current year Contain alate that belongs tothe previous year ‘Contain a date that belongs to next year ‘Yean[SalesDatep* 12 + Datevartt, Isalesbate) = veoribeteoy 12 + Dateparte im, Gateo)- 1 ‘veargsalesbatep* 12 + Daterantr |salesDateb = YeartDateoy 12 + Dateparten, Bateo) + 1 Between Datel) And DateddsM 4, Batec)) ‘Yean{SelesD ale) = YeariNow0) And Datepartc, Osteo) = DsteP=rt'q Nowe ‘ean[SalesDatep+DatePani'g) Isalespatep = ‘VearDatei)"t+DateParltg" Dateoy 1 ‘veardSalesdatep'4~Daterang’ [SalesDatep = ‘earDate[%s HDatevartn' Dsteg}+1 ‘ear(SelesDatep arate0) ‘ean[SelesDatep = Year(Date0) 1 ‘veardSalesbatep artDate0)* 1 Returns records forte previaus marth, today’s date is 22/2008, you see records fr Jan 2006 tums records forthe nest mont. today’s date is 2/2/2006, you see recorels for War 2006 ‘A mont worth of sales records. f today’s date is 2/2/2006, you see recore’s forthe period Jan 2, 206, t0 Fal 2, 2006 Returns records forthe current quarter. IF toxays cate 2/2/2008, you see recare's for the fist quarter of z00e, Rens recards forte prevaus quarter. today’s dete is 22/2008, you see records forthe last quarter of 2005 Returns record forthe next quarter if today’s date is 2/2/2006, you see recore’s forthe second quarter ef 2005. Returns records forthe current year toxays cate 2/2/2006, you see recor’: forthe year 2008 Returns ecards of transactions that tank place ering the previous year today's ate is 2/2/2006, you sue record for the year 2005, Returns record of transadions with next year's date IF today's dates 2/2/2006, yu see cecorcs far the year 2007 ‘contain a date that falls between Jen 1 sind taclay year te date records) ‘contain a date that curred in the past ‘contain a date that coccurts the sure Fiter for ral cor missing values Fiter for ron-mul values ‘YeardSalesDatep = YeartDateo) and Morith(SalesDaie) <= MonthiDated) and DaylSalesDate) <= Day ated) < pateg > vareg iso Is ter Mul Returns records of wansactions wih ates that fall between Jan 1 ofthe ‘urvene year and today. #toays cate ie 2/2/2008, you see records forthe perioe Jan 1, 2006 toto 2/2/2006, Returns records of transactions tha took place before today Return records of transactions thae ul ‘ake place after today, Return records where the date of ‘yansaction i ising, Return records were the date of ‘ransaton known, Criteria for Yes/No fields [As an example, your Customers table hat Yes/No feel named Active used to indicate whether & customer's accourt is curently active. The folowing t2ble shows how valies entered inthe Criteria row fora YesiNo Tele are evaluated, Field value Yes, Tue 1 oF 1 No, Fale or 0 No valve tnd ‘ny sumber otter than 1,1, or 0 Any character stong ether than Yes, Ho, tue, or False Result ‘Tested fora Ves yale A value of 1 or 1 is converted to "Tue" in the Criens tov after you enter it ‘Tested for a Po value. vale 00 is converted to False’ inthe Crteria row ater yeu enter octested Mo results iFies the only citer value inthe fle ‘Query alls ta run cue ta Dats type mismatch error

You might also like