Link to home
Start Free TrialLog in
Avatar of jasonbrandt3
jasonbrandt3

asked on

Format Date for active directory usage

I have a text box with an input mask of mm/dd/yyyy.  I'd like to use this date to query Active Directory whenCreated date.  Do I have to format this date to comply with Active Directory or will the current format work?
ASKER CERTIFIED SOLUTION
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is the method you need taken from the c# corner website (i take no credit):
public string ToADDateString(DateTime date)
{
string year = date.Year.ToString();
int month = date.Month;
int day = date.Day;
StringBuilder sb = new StringBuilder();
sb.Append(year);
if (month <10)
{
sb.Append("0");
}
sb.Append(month.ToString());
if (day <10)
{
sb.Append("0");
}
sb.Append(day.ToString());
sb.Append("000000.0Z");
return sb.ToString();
}

Open in new window

Could you please check the solution and confirm if its helpful?
Avatar of jasonbrandt3
jasonbrandt3

ASKER

perfect, thanks!
Thanks. Appreciate your reply