This was the answer that helped me, from Stack Overflow , translated into Portuguese:
If you want to set the default value to DateTime.Now
, or allow it to be another value, you'll probably want code similar to this:
Dim magicDate = If(Not String.IsNullOrWhiteSpace(
ConfigurationManager.AppSettings("OverrideMagicDate")),
Date.Parse(ConfigurationManager.AppSettings("OverrideMagicDate")),
Date.Now)
In the file app.settings
, leave the value of OverrideMagicDate
empty if you want it to receive DateTime.Now
or enter the date you want:
<add key="OverrideMagicDate" value="" /><!-- DateTime.Now -->
or:
<add key="OverrideMagicDate" value="2012-01-13" /><!-- 13/01/2012 -->
You may need to swap Parse
by ParseExact
if you want have greater control over date formats.