Compare current Month with 6/26/2001 ???

Results 1 to 2 of 2

Thread: Compare current Month with 6/26/2001 ???

  1. #1
    Patty Guest

    Default Compare current Month with 6/26/2001 ???

    I have a MsAccess tbl_stats table and a date field named DateOfHit_date in the mm/dd/yyyy format. Example of records:<BR><BR>6/18/2001<BR>6/18/2001<BR>3/18/2001<BR>6/26/2001<BR>6/15/2001<BR>6/15/2001<BR>4/5/2001<BR>...<BR><BR>What I am trying to do is Select all the records that are equal to the current month (6th month). I&#039;ve tried to do the following:<BR><BR>getStatsMonth = "SELECT * FROM tbl_stats WHERE DateOfHit_date="& month(now)<BR><BR>Results:<BR>(through a do while loop i count the # of records and display the total # of hits)<BR># of de hits for the current month: 0<BR><BR>I&#039;ve also tried the follwing:<BR>getStatsMonth = "SELECT * FROM tbl_stats WHERE DateOfHit_date=#"& month(now) &"#"<BR><BR>Results:<BR>Syntax error in date in query expression &#039;DateOfHit_date=#6#&#039;.<BR><BR>Anyone knows how can I do day, month and year comparisions without using 3 different fields in the DB for each ???<BR><BR>Thanks in advance.<BR>Patty

  2. #2
    Join Date
    Dec 1969

    Default Use DatePart

    This should work<BR><BR>getStatsMonth = "SELECT * FROM tbl_stats WHERE DatePart(&#039;m&#039;,[DateOfHit_date])="& DatePart(&#039;m&#039;,Date())

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts