Consider using a date-specific component. Having said that, I will try to find a solution that seems to be just what you need:
DateTime dataInicio;
if (!DateTime.TryParse(textbox_inicio.Text, out dataInicio)) {
lblErro.Text = "Formato da data inicial é inválido";
lblErro.Visible = true;
return;
}
DateTime dataFim;
if (!DateTime.TryParse(textbox_fim.Text, out dataFim)) {
lblErro.Text = "Formato da data final é inválido";
lblErro.Visible = true;
return;
}
if (DateTime.Compare(dataInicio.Date > dataFinal.Date) {
lblErro.Text = "Data inicial não pode ser superior à data final";
lblErro.Visible = true;
} else {
lblErro.Text = "";
lblErro.Visible = false;
}
I put in the Github for future reference.
This is just a base, you can do better than this and you probably need to adapt to what you need since you didn’t post your code.
Put in your code so far
– Maniero
What is the Database?
– Tony