Header Scripts

When exporting a PostgreSQL database to another database server, such as MySQL or MS SQL Server, the date field will appear as a number if it is saved as an Excel sheet. After spending some time trying to determine what the number means, I found that it seems to represent the number of days from January 1, 1900.

The problem is that when I test the date with the C# code below, the actual date in the database is off by 2 days. This may be the result of the original PHP application not calculating the date correctly from the Postges database. I doubt that Postgres would have the first entry of the date field starting on January 3, 1900.


int iDays = 39970;          // number of days since January 1, 1900

DateTime StartTime = new DateTime (1900, 1, 1);
DateTime EndTime = StartTime.AddDays (iDays);

Console.WriteLine (EndTime.ToString ());

Print Friendly, PDF & Email
Translate ยป