Trocar barras de uma data que esta numa string por traço:
string sVariavelNova = DateTime.Now.ToString(“yyyy/MM/dd”).Replace(“/”, “-“);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Capturar data do sistema com o formato ano/mês/dia no C#:
DateTime.Now.ToString(“yyyy/MM/dd”);
DateTime.Now.ToString(“HH:mm:ss”);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Outra maneira de manipular datas:
string dia = DateTime.Now.Day.ToString();
string mes = DateTime.Now.Month.ToString();
string ano = DateTime.Now.Year.ToString();
string VDataDoSistema = dia+mes+ano;
string VHoraSistema = DateTime.Now.ToShortTimeString();
string VDataDoSistema = DateTime.Now.ToString(“yyyy/MM/dd”);
string VHoraSiistema = DateTime.Now.ToString(“HH:mm:ss”);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if(DateTime.Today.Month > datePicker.Value.Month && DateTime.Today.Day > datePicker.Value.Day)
anos = DateTime.Today.Year – datePicker.Value.Year;
else
anos = DateTime.Today.Year – datePicker.Value.Year – 1;