SQL command to extract month info?

Results 1 to 2 of 2

Thread: SQL command to extract month info?

  1. #1
    Bill J. Guest

    Default SQL command to extract month info?

    One of my data tables is several hundred records large, and continually growing. I&#039m building an archive to break them down and display them a month at a time. <BR><BR>Problem is, the only way I currently know of to do that would be to cycle through every record individually, and test its month information via DatePart() to determine whether it should be displayed on the current page.<BR><BR>This method is obviously horribly inefficient. Is there any simple way (a modified SELECT WHERE statement, perhaps?) for me to select only records from a given month when I initially open the recordset?

  2. #2
    Ugh!! Guest

    Default RE: SQL command to extract month info?

    You can use DatePart as part of the WHERE clause in your SELECT statement:<BR><BR>SELECT &#060;columns&#062;<BR>FROM &#060;table&#062;<BR>WHERE DATEPART(m,&#060;yourdate&#062;) = @MonthYouWant<BR><BR>Good Luck<BR><BR>Ugh!!<BR>http://www.cutajar.net/owen

Posting Permissions

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