Jump to content


Photo

SQL DATEs


  • Please log in to reply
No replies to this topic

#1 interrupt

interrupt
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 28 February 2006 - 12:07 AM

Hello out there,
I am trying to get the same data that I was getting from mysql through mssql
very common mistake, i am sure

here is the mysql query string that worked fine to get some data through php mysql functions

$sql = "SELECT A.id, A.url, A.title, A.body, B.name, B.url as feedurl,
DATE_FORMAT(A.dt, '%H:%i') as time,
DATE_FORMAT(A.dt, '%W %D %M %Y') as date
FROM lylina_items A, lylina_feeds B, lylina_userfeeds C
WHERE B.id = A.feed_id
AND B.id = C.feed_id
AND C.user_id = $UID
AND UNIX_TIMESTAMP(A.dt) > UNIX_TIMESTAMP()-($hours*60*60)
ORDER BY A.dt DESC, A.title";


here is my new attempt when using an MSSQL database through php ODBC functions:

$sql = "SELECT A.id, A.url, A.title, A.body, B.name, B.url as feedurl,
getdate(A.dt, 'H:i:s') as time,
getdate(A.dt, 'Y-m-d') as date
FROM lylina_items A, lylina_feeds B, lylina_userfeeds C
WHERE B.id = A.feed_id
AND B.id = C.feed_id
AND C.user_id = $UID
AND (A.dt) > CURRENT_TIMESTAMP()-($hours*60*60)
ORDER BY A.dt DESC, A.title";

I am getting an error that says getdate() takes 0 parameters. and with no parameters there is an error involving syntax near a period..
I am definitely lost in this stuff. Let me know if I am leaving out important things..
I am looking for a way to get a formatted date through SQL grammar for an MSSQL database
thanks!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users