Thibauld - Imagination and Execution -

24Sep/100

postgresql, date input format and black magic

RT @thibauld postgresql, date input format and black magic

I hate when I have the impression that black magic took the control of my PC. If you're a developer, you know it happens sometimes... when something is obviously wrong but you just can't figure out *what* is wrong. Hopefully, we work in IT, a field where we can reasonably assume that *everything* happens for a reason. So after digging a while, you eventually end up finding where the issue comes from.

It happened this week while trying to figure out why Postgresql had a different behavior on apparently completely similar platforms. I'm born April 1st, let's say I want to save my birthday in a table, I'd go with the following SQL statement :
INSERT INTO birthdays (date) VALUES ('01-04-1981');

As I'm french, each time I deal with dates, I tend to verify that they were understood correctly. Indeed, the above date format was french ('dd-mm-YYYY') but postgresql could have interpreted as a US date format ('mm-dd-YYY'). So let's check with the following statement:
SELECT date_part('month',date) FROM birthdays;

Here comes the problem. On 2 different machines with (apparently) the same setup, this statement would return 2 different results. One would return '04' (correct) and the other one would return '01' (wrong).

I took me a while to find out that postgresql had datestyle option (in postgresql.conf) which defines the rule to interpret ambiguous date input values.

So if datestyle is set to 'iso, dmy', it means dates will be interpreted as 'date-month-year' and if it is set to 'iso-mdy', dates will be interpreted as 'month-date-year'. It is that simple... once you found it :)

15Dec/092

Société Générale en panne ?

RT @thibauld Société Générale en panne ?

J'aime quand le site de ma banque fonctionne bien... sans commentaires



societe_generale_website

31Aug/080

Bug squashing goes on… and new position!

RT @thibauld Bug squashing goes on… and new position!

Beginning of september, despite a truly awful weather in Paris, I'm glad because today I had my first 'official' bug report on google code! The bug is still open right now but obviously I will try to fix as soon as I can!

Some of you noticed that I'm a little bit less reactive these times on savemyconf, that's true and it's because I accepted working as a CTO on another cool project. It means that most of my time in august and september is dedicated to Freelance Business Club, a social network for freelances in IT that has a lot of potential. They are currently in beta and my role is basically to technically turn this beta into a v1.0 version, a very good experience! For info, the new version will be released in end october...

And here's my new business card:

Nouvelle carte de visite

Don't you find it pretty ? :)

Obviously, working for Freelance Business Club slows me down a little on savemyconf, but development on savemyconf goes on! More about that soon...

Filed under: announcements, bug, fbc No Comments