Calculating the Date from Exported PostgreSQL Table
Posted by Johan Cyprich on 14 Dec 2009 | Tagged as: Programming
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 ());
| Related posts: | |
|
|
Share this post:
Follow Me:
Did you find this post interesting and useful? You can keep up to date on this blog by subscribing to my RSS feed, or you can have new posts sent to you by e-mail. You can also follow me on Twitter.
No Comments »
Tweet This Post!















