Hi, i am trying to sort out some code to return me a date range for any given month from the start of the month to the end of the month (also for a quarter ie. Jan - Mar, etc...) Please can anyone help???
The code below is what i use to determin the start and end of a week.
request.form("Period" is 1 to 52
YearStart = DateSerial(Year(Date()), 1, 1)
WeekStart = (YearStart - DatePart("w", YearStart)) + 1
WeekEnd = WeekStart + 6
Week_Number = request.form("Period"
WeekStart_Var = FormatDateTime(WeekStart + (7 * (Week_Number - 1)) ,vbShortDate)
WeekEnd_Var = FormatDateTime(WeekEnd + (7 * (Week_Number - 1)) ,vbShortDate)
Week_Start_dd_var = Cstr(Day(WeekStart_Var))
Week_Start_mm_var = Cstr(Month(WeekStart_Var))
Week_Start_yyyy_var = Cstr(Year(WeekStart_Var))
Week_End_dd_var = Cstr(Day(WeekEnd_Var))
Week_End_mm_var = Cstr(Month(WeekEnd_Var))
Week_End_yyyy_var = Cstr(Year(WeekEnd_Var))
If Week_Start_dd_var < 10 Then Week_Start_dd_var = "0" + Week_Start_dd_var
If Week_Start_mm_var < 10 Then Week_Start_mm_var = "0" + Week_Start_mm_var
If Week_End_dd_var < 10 Then Week_End_dd_var = "0" + Week_End_dd_var
If Week_End_mm_var < 10 Then Week_End_mm_var = "0" + Week_End_mm_var
DateRange = Week_Start_dd_var + "/" + Week_Start_mm_var + "/" + Week_Start_yyyy_var + " 00:00:00" + " - " + Week_End_dd_var + "/" + Week_End_mm_var + "/" + Week_End_yyyy_var + " 23:59:59"
Kind Regards.
The code below is what i use to determin the start and end of a week.
request.form("Period" is 1 to 52
YearStart = DateSerial(Year(Date()), 1, 1)
WeekStart = (YearStart - DatePart("w", YearStart)) + 1
WeekEnd = WeekStart + 6
Week_Number = request.form("Period"
WeekStart_Var = FormatDateTime(WeekStart + (7 * (Week_Number - 1)) ,vbShortDate)
WeekEnd_Var = FormatDateTime(WeekEnd + (7 * (Week_Number - 1)) ,vbShortDate)
Week_Start_dd_var = Cstr(Day(WeekStart_Var))
Week_Start_mm_var = Cstr(Month(WeekStart_Var))
Week_Start_yyyy_var = Cstr(Year(WeekStart_Var))
Week_End_dd_var = Cstr(Day(WeekEnd_Var))
Week_End_mm_var = Cstr(Month(WeekEnd_Var))
Week_End_yyyy_var = Cstr(Year(WeekEnd_Var))
If Week_Start_dd_var < 10 Then Week_Start_dd_var = "0" + Week_Start_dd_var
If Week_Start_mm_var < 10 Then Week_Start_mm_var = "0" + Week_Start_mm_var
If Week_End_dd_var < 10 Then Week_End_dd_var = "0" + Week_End_dd_var
If Week_End_mm_var < 10 Then Week_End_mm_var = "0" + Week_End_mm_var
DateRange = Week_Start_dd_var + "/" + Week_Start_mm_var + "/" + Week_Start_yyyy_var + " 00:00:00" + " - " + Week_End_dd_var + "/" + Week_End_mm_var + "/" + Week_End_yyyy_var + " 23:59:59"
Kind Regards.