By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,480 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,480 IT Pros & Developers. It's quick & easy.

Converting DOS date to mmddyyyy format in C#

P: n/a
I am working on an application that stores date in DOS format. For ex:
9540 which appears to be the number of days since 1980. Anyone knows a
way to convert this into the mmddyyyy format?

Thanks in advance.

Feb 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I am working on an application that stores date in DOS format. For ex:
9540 which appears to be the number of days since 1980. Anyone knows a
way to convert this into the mmddyyyy format?


How about

new DateTime(1980, 1, 1).AddDays(yourDateValue).ToString("MMddyyyy");
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 23 '06 #2

P: n/a
Just create a different class with static methods

public class DOSDateTimeFormat
{
public static DateTime ConvertFrom(string dt_value)
{
return new DateTime(1980, 1, 1).AddDays(dt_value);
}

public static string ConvertTo(DateTime dt)
{
return ( dt.Subtract(new DateTime(1980, 1, 1))
).ToString("MMddyyyy");
}
}

That way it can be reusable and you can put the class in a utility
assembly.

Sincerely,
Bobby

Feb 24 '06 #3

P: n/a
Does
DateTime.FromOADate( <double> )

do it for you? It takes a date as a double (number of days since...) and
converts it to a DateTime.

Steve

"spdude" <sa*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I am working on an application that stores date in DOS format. For ex:
9540 which appears to be the number of days since 1980. Anyone knows a
way to convert this into the mmddyyyy format?

Thanks in advance.

Feb 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.