Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

I have the monthCalendar tool and I would like to select 5 random dates in the calendar. Those 5 random dates should appear in one textbox in order to save it to my database (mysql).

What I have tried:

I saw many forums but most of the SelectionRange tutorial has a start date and an end date. What I need is to record that 5 random dates inside one textbox.

Thank you so much for your answers..
Posted
Updated 14-Aug-18 2:47am

1 solution

hi ,

you can use this method :
DateTime GenererateRandomDate()
{

    int year = rnd.Next(1900, 9999);
    int month = rnd.Next(1, 12);
    int day = DateTime.DaysInMonth(year,month);

    int Day = rnd.Next(1, day);

    DateTime dt = new DateTime(year,month,Day);
    return dt;
}


this will generate you 1 date , you can store the returns date in a list and then show the list date in the textbox. Maybe you can use string.join to make them in one string.

Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900