datetime.now

  • Thread starter Thread starter mp
  • Start date Start date
M

mp

I am using :
SystemDate= System.DateTime.Now.Year.ToString()
+System.DateTime.Now.Month.ToString()+System.DateTime.Now.Day.ToString();

strbRetVal.AppendFormat("{0}{1}",SystemDate,m_chFieldDelimiter);



but this gives me : 200517

I want the date to look like: 20050107

How can I do this?



Thanks
 
mp,

You should make the call to DateTime.Now only once. You could have an
issue if this runs around midnight at the end of the year (very small, but
definitely possible).

Rahter, do this:

// Append the format.
strbRetVal.AppendFormat("{0:yyyyMMdd}{1}", DateTime.Now,
m_chFieldDelimiter);

That should work.

Hope this helps.
 
Back
Top