Monthly Archives: January 2010

Microsoft Excel date dilemma

I was recently exporting a Microsoft Excel SpreadSheet to a data base. I was using Apache POI to read the excel sheet. To my utter surprise, I was getting the date as some numeric value. I initially thought it was the Unix epoch, but it turned out wrong. I then applied my “dirty-fix” talent, rather than googling. 17-Jan-09 was 39830. 39830/365 = 109. So I gathered that this Microsoft Epoch started from 1st Jan 1900. I was not entirely wrong. But it actually starts from 31st December 1899 :). So, 31st December 1899 is the Day 1 in Microsoft Terminlogy. The Microsoft guys goofed up in the leap year thing, so they lost one day. I know this as I googled a bit today, and came across this. So, the Microsoft Epoch really should have been 1st Jan 1900. Better luck next time :).

I would love to share the code with you:

Note that I am getting a float for the date, which I am converting to String, for purely ease of handling.

Installing postgres on Fedora

In Fedora 7+, postgres is insatlled by default. Its just about a few commands to get started. First of all you have to change the password for the postgres user, postgres. I am pasting the commands below:

#passwd postgres
#chown postgres /var/lib/pgsql/data/
#su – postgres
~initdb -D /var/lib/pgsql/data/
#/etc/rc.d/init.d/postgresql start

You can also install pgadmin3, which is a nice GUI for postgres:

#yum install pgadmin3

If you do not have the repository, you can add it from here:

I was inspired by this blog:

Update As On 18th July 2014

After a long break, I am again back, trying to install Postgres. It has become lot easier. Just installed it using the rpm available on the site. It was smart enough to create the user postgres for me.

A few essential post install tweaks are necessary.

Note: The below steps have to be done while logging in as the unix user postgres.

Changing the authentication method from peer and ident to md5

By default, postgres has the unix user postgres as the only user. Now, you would like to change that. Edit the pg_hba.conf. Typically in Fedora it would be under the /var/lib/pgsql/data. Change it so that the below section looks like:

# “local” is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all               md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Then through psql, change the user role of the postgres user:

alter user postgres with password ‘mypassword’;

Now restart the service for these changes to take effect.

Making the database accept TCP/IP connection

Edit the postgresql.conf and un-comment the below line:

listen_addresses = ‘localhost’

After completing the above 2 steps, you should be all set!