๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์„ ํ˜ธํ•˜๋Š”๊ฐœ๋ฐœ

[c#] ๋‚ ์งœ ํฌ๋งท ํ™•์ธ ํ›„ ์ •์ƒ์ ์ผ ๊ฒฝ์šฐ ๋‚ ์งœ ํฌ๋งท์œผ๋กœ ๋ฐ˜ํ™˜ DateTime.TryParse

[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