Jump to content

SQL DATEs


interrupt

Recommended Posts

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!
Link to comment
https://forums.phpfreaks.com/topic/3713-sql-dates/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.