Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.