emi_sastra
asked on
GET CERTAIN DATES
Hi All,
I want to set default dates with condition :
1. If Current Date is Tuesday To Sunday
FromDate = Last Sunday Date
ToDate = Current Date
2. If Current Date = Monday
FromDate = Sunday before Yesterday of Current Date
ToDate = Saturday
How could I do it ?
Thank you.
I want to set default dates with condition :
1. If Current Date is Tuesday To Sunday
FromDate = Last Sunday Date
ToDate = Current Date
2. If Current Date = Monday
FromDate = Sunday before Yesterday of Current Date
ToDate = Saturday
How could I do it ?
Thank you.
ASKER
Hi cyberkiwi,
Why toDate always Today?
If today is monday then show sunday to saturday of last week
If today is > monday then show recent sunday to today.
Thank you.
Why toDate always Today?
If today is monday then show sunday to saturday of last week
If today is > monday then show recent sunday to today.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, it works.
Thank you very much for your help.
Thank you very much for your help.
Select Case Today.DayOfWeek
Case DayOfWeek.Monday : offset = -8
Case DayOfWeek.Tuesday : offset = -2
Case DayOfWeek.Wednesday : offset = -3
Case DayOfWeek.Thursday : offset = -4
Case DayOfWeek.Friday : offset = -5
Case DayOfWeek.Saturday : offset = -6
Case DayOfWeek.Sunday : offset = -7
End Select
Dim fromDate as Date = DateAdd(DateInterval.Day, offset, Today)
Dim toDate as Date = Today
If Today.DayOfWeek = DayOfWeek.Monday Then
fromDate = DateAdd(DateInterval.Day, -2, Today)
End If