November 20th, 2003, 03:22 PM
I almost converted the whole thing and feeling like I need a beer!
One more question though, in my mysql database I stored the date in a field with datetype 'datetime'.
When I wanted to get this info out of de database I used the query:
Now in postgreSQL I stored the date in a field with datetype 'timestamp' cause 'datetime' is unavailable in postgres.
$query = "SELECT sectionid,subsection,subsectionid,date_format(date, '%d\/%m\/%Y %H\:%i\:%s') FROM content";
How should I go about getting this date info out of the postgres database?
November 20th, 2003, 04:37 PM
Use the extract or date_part functions
Sorry I know that's not in your language (I'm assuming Dutch?), but hopefully it will be helpful. Basically you could just extract the parts of the date you want and concatenate them into one string (you do string concatenation with || ).
You may also want to look into SET DateStyle .
If you can't figure it out, just reply and I'll go into more detail when I got some time.
PostgreSQL, it's what's for dinner...
November 20th, 2003, 06:20 PM
Thanx for the url. And yep it's Dutch.
I found a solution that works but i'm not sure if it's the nicest
Here is my solution:
$query = "SELECT sectionid,subsection,subsectionid,to_char(date,'DD-MM-YY HH24:MI:SS') FROM content ORDER BY sectionid,subsectionid";
$result = pg_query($query) or die("Error");
while($row = pg_fetch_array($result,NULL,PGSQL_ASSOC))
These solutions remind me of math in highschool. I usually got the good answer but a complete wrong way of getting/calculating it
$date = date(Y."-".m."-".d." ".H.":".i.":".s);
$query = "UPDATE content SET content='$text',subsection='$Sectionname',date='$date',publiek='$public' WHERE sectionid = '$sectionID' AND subsectionid = '$subsectionID'";