Supply Date based on DOW
- From: "ct witter" <norcold1@xxxxxxxxx>
- Date: 27 Dec 2005 12:10:40 -0800
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
.
- Prev by Date: Re: Distinct not working when convert DATE using TO_CHAR
- Next by Date: Re: Supply Date based on DOW
- Previous by thread: Supply Date based on DOW
- Next by thread: Re: Supply Date based on DOW
- Index(es):
Relevant Pages
|
|