471,350 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Converting DOS date to mmddyyyy format in C#

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
3 4912
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
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
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.

Similar topics

2 posts views Thread by Fran Zablocki | last post: by
5 posts views Thread by Jack | last post: by
2 posts views Thread by Florida . NET Coder | last post: by
18 posts views Thread by David Gacek | last post: by
20 posts views Thread by andreas | last post: by
2 posts views Thread by Stevienashaa | last post: by
3 posts views Thread by veaux | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.