I wrote the code, but I can get all the dates. How to get a date in the current month?
String connectionString = @"data source = localhost; initial catalog = StudentsBirthday; integrated security = SSPI;";
SqlConnection con = new SqlConnection(connectionString);
List<DateTime> birthdays = new List<DateTime>();
using (con)
{
con.Open();
SqlCommand cmd = new SqlCommand("Select Birthday From Students",con);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
birthdays.Add(reader.GetDateTime(0));
}
}
foreach (DateTime Birthday in birthdays)
{
Console.WriteLine(Birthday);
}
Console.ReadKey();