Supply Date based on DOW



Converting from vb to SQL: Below is my orginal logic:

Select Case Weekday(Date, vbSunday)
Case Is = 1
' We are at a Sunday so we need to go
' to previous Thursday
txtStartDate = DateAdd("d", -3, Date)
Case Is = 2
' We are at a Monday so we need to go
' to previous Thursday
txtStartDate = DateAdd("d", -4, Date)
Case Is = 3
' We are at a Tuesday so we need to go
' to previous Thursday
txtStartDate = DateAdd("d", -5, Date)
Case Is = 4
' We are at a Wednesday so we need to go
' to previous Tuesday
txtStartDate = DateAdd("d", -1, Date)
Case Is = 5
' We are at a Thursday so we need to go
' to previous Tuesday
txtStartDate = DateAdd("d", -2, Date)
Case Is = 6
' We are at a Friday so we need to go
' to previous Tuesday
txtStartDate = DateAdd("d", -3, Date)
Case Is = 7
' We are at a Saturday so we need to go
' to previous Thursday
txtStartDate = DateAdd("d", -2, Date)
Case Else
txtStartDate = Date
End Select

Logic is Saturday - Tuesday (Date=Previous Thursday, Otherwise
Date=Previous Tuesday

So today (27/12/2005) Date = 27/22/2005.

Any suggestions??

Thanks,
CT

.



Relevant Pages

  • Re: What Database model should I use?
    ... If you want to upgrade to a serious DBMS you did not list SQL Server. ... Porting Access/JET databases can be done with the upsizing wizard as ... I would also read about coding ADO a bit more. ... > But I am having a problem converting the MS Access JET databases. ...
    (microsoft.public.vb.database)
  • Re: Assoc method on large array
    ... SQL recordset array each record was actually a DBI::Row object and not ... After converting these DBI::Row ... coding in Ruby better than coding in SQL I figured I'd let Ruby do the ...
    (comp.lang.ruby)
  • Re: Poor Peformance from 2K Version
    ... JET 4 is able to use the old format. ... going to be network and other issues, as converting data on the fly would be ... any sql that uses VBA functions in the sql can run SIGNIFICANTLY ... the FIRST thing to try is the persistent connection trick...it ...
    (microsoft.public.access.modulesdaovba)
  • Re: Linked SQL Table into Access -1 doesnt register
    ... Thanks for the nodelete script. ... Seems like I'm going to have a few roadblocks when I come to converting ... stuff straight from Access to SQL. ... set rst = db.openrecordset ...
    (comp.databases.ms-access)
  • ODBC/VBA?EXCEL and ORACLE database
    ... We recently converted one of our datawarehouses to ORACLE. ... I am now having difficulty converting several Excel Macros that use VBA ... With a SQL Syntax error. ... function is required to override ORACLE default format of:date Timestamp" ...
    (microsoft.public.excel.programming)