0

My program is reading data from SQL Server like this:

if (!reader.IsDBNull(4))
{
    message.WazneDo = reader.GetDateTime(4);
}

This code read datetime from SQL Server. Then I will load it to datagridview:

WypozyczZwrocDb _dost1 = new WypozyczZwrocDb();
Global.listWypozyczZwroc = _dost1.PokazZar();
Global.fMain.Tabela.DataSource = Global.listWypozyczZwroc;

How to compare with today's date? I want change the row color.

I tried:

DateTime dzis = DateTime.Now;

if(Tabela.Rows[Tabela.CurrentCell.RowIndex].Cells[4].Value > dzis)

if(Tabela.Rows[Tabela.CurrentCell.RowIndex].Cells[4].Value > dzis.ToString())
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

DateTime.Compare() will allow you to use comparative operators in a conditional statement based on the int returned.

DateTime.Compare() msdn

Gabe
  • 570
  • 1
  • 4
  • 15