Date processing with PostgreSQL

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

Post Reply
MartinTeefy
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 24.11.2009, 17:17

Date processing with PostgreSQL

Post by MartinTeefy »

Hi,

I'd like to add PostgreSQL as a supported database for my helpdesk system. 95% of the SQL statements are generic via the keys being numeric in the main but I have some date related questions:

When i do an insert or update to a table what is the equivalent to MSSQL system variables Getdate() or MySQL's Curdate()

What is the best way to Select data using a datetime field or the equivalent of either SQL statements:

MySQL:

SELECT Count(*) FROM AON_APPOINTMENTS WHERE AP_USER_ID = gCurrentAppointee & " AND DATE_FORMAT(AP_START_DATETIME,%Y-%m-%d) = '" & Format(eachDay, "YYYY-MM-DD") & "'"

SQLite:

SELECT Count(*) FROM AON_APPOINTMENTS WHERE AP_USER_ID =
gCurrentAppointee & " AND DATE(AP_START_DATETIME) = '" & _
Format(eachDay, "YYYY-MM-DD") & "'"

Any advice is much appreciated
Martin
Wild_Pointer
Expert Boarder
Expert Boarder
Posts: 164
Joined: 18.03.2008, 13:03
Contact:

Post by Wild_Pointer »

Hello, Martin.

in postgresql current date can be obtained using CURRENT_DATE. For formating date field please use to_char function.

Good luck!
Post Reply