SQL question.

Results 1 to 2 of 2

Thread: SQL question.

  1. #1
    Join Date
    Dec 1969

    Default SQL question.

    How do I write my SQL statement so that it will only return records with a date field 18,6,3,2,1 or 0 months from the current date?<BR>I know you can assign all of the recordsets to an array then display only the ones that meet that criteria through by using datediff but how do I only select and assign the ones that match that criteria from the beginning?<BR>Thanks<BR>Wally

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL question.

    declare @today int<BR>set @today = getdate()<BR><BR>Select DateField from Table <BR>where <BR> datediff(m,Datefield,@today)&#060;3<BR> or datediff(m,Datefield,@today)=6<BR> or datediff(m,Datefield,@today)=18<BR><BR>sponge

Posting Permissions

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