Mikelemuel Mikelemuel - 1 month ago 9
Vb.net Question

ASP.NET : Accepting dates of validation in MMYYYY format using Dropdown list USING VISUAL BASIC

Scenario.
I have a dropdown list of Month(1-12) and Year (MMYYYY) format.
Start Date : Month(1-12) and Year (MMYYYY) format
End Date : Month(1-12) and Year (MMYYYY) format

If I would select the START DATE : 10/2018 (then the start date is valid)
start date should not be more than 5 years based on the current year
Then the "END DATE" should be End DATE : 10/2018 ( this is valid)


  1. HOW CAN I ACCEPT THE START THE SHOULD NOT BE MORE THAN 5 YEARS FROM CURRENT DATE?

  2. HOW CAN I ACCEPT THE END DATE THAT SHOULD NOT BE MORE THAN 5 YEARS FROM THE START DATE?



If achieved, another question:


  1. HOW CAN I VALIDATE Month - START DATE : 10/2018 END DATE : 10/2018

  2. HOW CAN I VALIDATE Quarterly - START DATE : 01/2018 END DATE : 03/2018.

    *Quarterly are (Jan to Mar, Apr to Jun, July to Sep, Oct to Dec)

  3. HOW CAN I VALIDATE Semi-annual - START DATE : 01/2018 END DATE : 06/2018 *SEMI - ANNUAL ARE ( JAN TO JUN, JULY TO DECEMBER)

  4. HOW CAN I VALIDATE ANNUAL - START DATE: 01/2018 END DATE: 12/2018



ELSE INVALID

OUTPUT: VALID OR INVALID.

EXAMPLE:

INPUT- START DATE: 10 2018 END DATE: 10 2018
OUTPUT: VALID ** THIS IS MONTHLY

INPUT- START DATE: 10 2018 END DATE: 12 2018
OUTPUT: VALID ** THIS IS QUARTERLY

INPUT- START DATE: 10 2018 END DATE: 03 2019
OUTPUT: VALID ** THIS IS SEMI-ANNUAL

INPUT- START DATE: 01 2018 END DATE: 12 2018
OUTPUT: VALID ** THIS IS ANNUAL

Answer

The latter part of your question should probably be a new question on SO. However, here goes...

HOW CAN I ACCEPT THE START THE SHOULD NOT BE MORE THAN 5 YEARS FROM CURRENT DATE?

HOW CAN I ACCEPT THE END DATE THAT SHOULD NOT BE MORE THAN 5 YEARS FROM THE START DATE?

You can create a date variable using the drop down list values, but each assume the first day of the month because a date needs a DAY part:

Dim dateStart As Date = New Date(ddl_dateStartYear.SelectedValue, ddl_dateStartMonth.SelectedValue, 1)
Dim dateEnd As Date = New Date(ddl_dateEndYear.SelectedValue, ddl_dateEndMonth.SelectedValue, 1)
' Today check
If dateEnd > DateTime.Now.AddYears(5) Then
    ' Invalid
End If
' Five year check
If dateStart.AddYears(5) > dateEnd Then
    ' Invalid
End If

HOW CAN I VALIDATE Month - START DATE : 10/2018 END DATE : 10/2018

This is done automatically when the new date variable is created.

2)HOW CAN I VALIDATE Quarterly - START DATE : 01/2018 END DATE : 03/2018...

I'm afraid I don't understand the rest of your questions. Perhaps delete these and place in a new question with more detail.