| When passing a date (format of DD/MM/YYYY) and a three letter code for a day of the week (Mon, Tue, Wed etc...) to this function, it will calculate the date of that day from the date given Useful To work out a week ending Date If you never know that users will ALWAYS specify a week-ending date. This is the first Function of it's kind on PSC. If it's any use, please vote. You must pass the date you wish to calculate from and then the TLA of the day name. For example, Mon = Monday, Tue = Tuesday, Wed = Wednesday, etc... Will return the calculated date of the day name given. Private Sub Form_Load() MsgBox Calculate_Week_Ending_Date(Format(Now, "DD/MM/YYYY"), "Fri") End Sub Function Calculate_Week_Ending_Date(Date_String As String, Week_Ending_Day As String) Dim Day_Increment As Integer Day_Increment = 0 For Day_Increment = 0 To 6 If Format(DateAdd("d", Day_Increment, Date_String), "ddd") = Week_Ending_Day Then Calculate_Week_Ending_Date = DateAdd("d", Day_Increment, Date_String) Exit Function End If Next Day_Increment End Function |
Calculate week ending date from current date |
Freelance ASP PHP web development | Web developer India Web development India| Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design