Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 phpbb date conversion

Author  Topic 

bdee1
Starting Member

8 Posts

Posted - 2004-06-09 : 08:54:21
i use PHPbb on windows/SQL server platform. it works well, but i want to write custom code to dump some post info onto another page of my site.

when i look at the post_time feild of the phpbb_posts table, the format is int and the value looks like this: 1086107973

so i have read that MYSQL has a function i can use called FROM_UNIXTIME which can convert this into a standard date format, but is there something equivalent to this in MSSQL Server?

John Obelenus
Starting Member

10 Posts

Posted - 2004-06-09 : 09:04:55
You should be able to use DATEPART(hh, 108610793) to get the hour, as an example.. if you look at Books onLine (free download from MS), and search for the datepart function, there is a table for all those 2letter prefixes...
Go to Top of Page

bdee1
Starting Member

8 Posts

Posted - 2004-06-10 : 10:23:55
Unfortunately that did not work - when i ran a query that looks like this:
SELECT DATEPART(hh, post_time) AS PostTime
FROM phpbb.phpbb_posts


i got an error that said:
Arithmetic overflow error converting expression to data type datetime. 


am i doing something wrong
Go to Top of Page

JasonGoff
Posting Yak Master

158 Posts

Posted - 2004-06-10 : 10:29:31
DATEPART expects a DATETIME type, not an int. It is trying to implicitly convert the int value in post_time to a DATETIME and failing. You need to find a way, as per your original question, to convert the unix time (if that's what it is), to a SQL-accepted date format. What data type is the post_time field ?
Go to Top of Page

bdee1
Starting Member

8 Posts

Posted - 2004-06-10 : 10:35:07
the datatype for post_time is int, length:4.

it seems like there must be a way to convert this to a valid date format.
Go to Top of Page

JasonGoff
Posting Yak Master

158 Posts

Posted - 2004-06-10 : 10:38:39
It might be a proprietary number generated by PHPbb for storing dates, e.g. the number of seconds since a given date. Check the PHPbb documentation to find out. You may be able to reverse-engineer a conversion back again.
Go to Top of Page

bdee1
Starting Member

8 Posts

Posted - 2004-06-10 : 10:40:12
boy, what a pain - why couldnt they just use a standard date format.
Go to Top of Page
   

- Advertisement -