SELECT statement with Date stuff

Results 1 to 2 of 2

Thread: SELECT statement with Date stuff

  1. #1
    Join Date
    Dec 1969

    Default SELECT statement with Date stuff

    Okay, I have a SELECT statement as shown below:<BR><BR>MonthSQL = "SELECT DISTINCT datepart(M,start) as start1 FROM dtlc WHERE start &#062; &#039;"& now &"&#039; ORDER BY start1 ASC;"<BR>Set MonthRS1 = escmyconn.Execute(MonthSQL)<BR><BR>This select statement populates a dropdown box so people can pick what month they would like to browse for a class. I added in the WHERE start &#062; &#039;"& now &"&#039; so that if a month has come and gone, it will not be displayed. Plus, this currently displays them in correct order (January, February, March...). But, if I add a class for January 2003, and it is Feb 02, it places January in front of February. I want Jan 03 to come after Jan Feb 02. If I add "start" to the SELECT statement and then do an ORDER BY start instead of start1, it grabs several of start1 and places them in the list, so I end up with 3 february&#039;s, 2 march&#039;s etc etc.<BR><BR>Has anyone done anything similar to this? Can anyone help me?<BR><BR>-ferretworks

  2. #2
    Join Date
    Dec 1969

    Default RE: SELECT statement with Date stuff

    If you want to populate a select with month names beginning at current month and going to next year (names of next 12 calendar months) then try:<BR><BR>M=Month(Date())<BR>Y=Year(Date())<BR>F or j = 0 to 11<BR>str = MonthName(DatePart("m",DateSerial(Y, M + j, 1)),true)<BR> &#039;code to build your options here<BR>Next

Posting Permissions

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