Getting the Build Date from a .Net Version Number

If only the first two parts of the version number (major and minor version) are specified in the code and an asterisk is added for the others then the last two parts will be populated automatically: the third part (the build number) is the number of days since the beginning of 2000 and the fourth part (the revision) is the number of seconds since midnight, divided by 2.

[assembly: AssemblyVersion("2.4.*")]

This ensures that build numbers are unique (provided you do not do more than one a second!) and that later builds always have larger version numbers.

A useful side-effect is that it is possible to get the build date (local time) from the version number:

public static DateTime GetBuildDateFromVersion()
{
    Version version = Assembly.GetExecutingAssembly().GetName().Version;
    DateTime refDate = new DateTime(2000, 1, 1);
    DateTime buildDate = refDate.AddDays(version.Build);
    buildDate = buildDate.AddSeconds(version.Revision * 2);
    return buildDate;
}