Select from one perticular month

Results 1 to 2 of 2

Thread: Select from one perticular month

  1. #1
    Join Date
    Dec 1969

    Default Select from one perticular month

    dear forum,<BR><BR>I have a little problem with my syntax.. I am trying to create a logbook over travel times. I would like to get a monthly overview of how much travelling I have done each month, but I am not sure how to do it. Each input into the database has a total time (TotTime), so I am trying to do something like this.. but I am not getting it right.. <BR><BR>strSQL = "SELECT SUM(TotTime) FROM Logbook where User=" & UserId & " AND Tripdate=#" & ????? & "#"<BR><BR>??? - what do I write here to select a summary of a specific month?? <BR><BR>thank you so much for your help,<BR>david froster

  2. #2
    Join Date
    Dec 1969

    Default There are various ways of doing this...

    ...but I tend to do the following:<BR><BR>SELECT ... WHERE MyDate &#062;= #2004/07/01# AND MyDate &#060; #2004/08/01#<BR><BR>Basically I&#039;m checking where the date is greater than or equals to (the equals is very important) to the first day of the month I want and less than (but NO equals to) the first day of the following month. If you then have additional conditions, just put the date part into brackets, like this:<BR><BR>SELECT ... WHERE MyField = 1234 OR (MyDate &#062;= #2004/07/01# AND MyDate &#060; #2004/08/01#)<BR><BR>There&#039;s another thing with your query though. If you want to do a SUM (which is an aggregate function) you need a GROUP BY clause. In your case that&#039;s probably the field User. See for more information.<BR><BR>Oliver.

Posting Permissions

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