Hallo Daniel,

hier ein Code-Snippet :
..
sql = "select ... .. .. . where .. .. "
..
select case timeRange
    case 1 'this month
      sql = sql & " and month(lastDate) = month(getdate()) "
    case 2 'this quart
      actMonth = month(date)
      if actMonth >= 1 and actMonth <= 3 then sql = sql & " and
month(lastDate) >= 1 and month(lastDate) <= 3 and year(lastDate) =
year(getdate()) "
      if actMonth >= 4 and actMonth <= 6 then sql = sql & " and
month(lastDate) >= 4 and month(lastDate) <= 6 and year(lastDate) =
year(getdate()) "
      if actMonth >= 7 and actMonth <= 9 then sql = sql & " and
month(lastDate) >= 7 and month(lastDate) <= 9 and year(lastDate) =
year(getdate()) "
      if actMonth >= 10 and actMonth <= 12 then sql = sql & " and
month(lastDate) >= 10 and month(lastDate) <= 12 and year(lastDate) =
year(getdate()) "
    case 3 'this year
      sql = sql & " and year(lastDate) = year(getdate()) "
    case 4 'last month
      sql = sql & " and month(lastDate) = (month(getdate())-1) "
    case 5 'last quart
      actMonth = month(date) - 3
      if actMonth >= 1 and actMonth <= 3 then sql = sql & " and
month(lastDate) >= 1 and month(lastDate) <= 3 and year(lastDate) =
year(getdate()) "
      if actMonth >= 4 and actMonth <= 6 then sql = sql & " and
month(lastDate) >= 4 and month(lastDate) <= 6 and year(lastDate) =
year(getdate()) "
      if actMonth >= 7 and actMonth <= 9 then sql = sql & " and
month(lastDate) >= 7 and month(lastDate) <= 9 and year(lastDate) =
year(getdate()) "
      if actMonth >= 10 and actMonth <= 12 then sql = sql & " and
month(lastDate) >= 10 and month(lastDate) <= 12 and year(lastDate) =
year(getdate()) "
    case 6 'last year
      sql = sql & " and year(lastDate) = (year(getdate())-1) "
end select

..

Hoffe das hilft... ?,
Gr��e
Patrick

> -----Original Message-----
> From: Daniel Steinh�ser [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 10, 2001 3:57 PM
> To: ASP Datenbankprogrammierung
> Subject: [aspdedatabase] Datumsgefrickel
> 
> 
> Hallo zusammen,
> 
> habe im Moment eine kleine Kopfsperre... ich m�chte gerne 
> Datens�tze mit
> folgenden Bedingungen abrufen:
> 
> alle Datens�tze aktueller Monat
> alle Datens�tze aktuelles Quartal
> alle Datens�tze aktuelles Jahr
> alle Datens�tze letzter Monat
> alle Datens�tze letztes Quartal
> alle Datens�tze letztes Jahr
> 
> Aber, wie m�ssen die Statements dazu lauten?
> Vielleicht kann mir jemand von euch helfen?
> 
> Vielen Dank im voraus,
> Daniel
> 
> | [aspdedatabase] als [EMAIL PROTECTED] subscribed
> | http://www.aspgerman.com/archiv/aspdedatabase/ = Listenarchiv
> | Sie k�nnen sich unter folgender URL an- und abmelden:
> | http://www.aspgerman.com/aspgerman/listen/anmelden/aspdedatabase.asp
> 
> _____________________________________________________________________
> This message has been checked for all known viruses by the 
> MessageLabs Virus Scanning Service. For further information visit
> http://www.messagelabs.com/stats.asp
> 

| [aspdedatabase] als [email protected] subscribed
| http://www.aspgerman.com/archiv/aspdedatabase/ = Listenarchiv
| Sie k�nnen sich unter folgender URL an- und abmelden:
| http://www.aspgerman.com/aspgerman/listen/anmelden/aspdedatabase.asp

Antwort per Email an