[c#] ๋ ์ง ํฌ๋งท ํ์ธ ํ ์ ์์ ์ผ ๊ฒฝ์ฐ ๋ ์ง ํฌ๋งท์ผ๋ก ๋ฐํ DateTime.TryParse
์์ธ์ฒ๋ฆฌ๊น์ง ๋์ด ์ค๋ฅ๋ฐ์ ์ํจ
DateTime Today = DateTime.Today;
DateTime dateTheDay;
string DDAY = string.Empty;
string TheDay = string.Empty;
TheDay = "2022-10-22 00:00:00";
if (TheDay.IndexOf("-") > 0)
{
if (DateTime.TryParse(TheDay, out dateTheDay))
{
TimeSpan Diff_dates = Today - dateTheDay;
DDAY = "D" + Diff_dates.Days.ToString();
}
}
// ์ถ๋ ฅํํ D-1 ,D0, D100
DateTime Today = DateTime.Today;
DateTime dateTheDay;
string DDAY = string.Empty;
string TheDay = string.Empty;
TheDay = "2022-10-22 00:00:00";
if (TheDay.IndexOf("-") > 0)
{
if (DateTime.TryParse(TheDay, out dateTheDay))
{
TimeSpan Diff_dates = Today - dateTheDay;
DDAY = "D" + Diff_dates.Days.ToString();
}
}
// ์ถ๋ ฅํํ D-1 ,D0, D100