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
 General SQL Server Forums
 New to SQL Server Programming
 someone please help me with this query

Author  Topic 

PrequelToTheSQL
Starting Member

2 Posts

Posted - 2012-05-06 : 22:24:11
im writing a query that calculates how many minutes it took for the first person to register to a website

the start time at 2012-3-13 17:22:00 and registration times are in a table

i think im using timediff function like this:

select timediff(minute, 2012-3-13 17:22:00, reg.registrationDateTime)
from reg
order by registrationDateTime
limit 1;

but this is not working... what am i doing wrong?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-06 : 22:50:55
are you using sql server? limit and timediff are not t-sql functions. you should be using top and datediff instead

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

PrequelToTheSQL
Starting Member

2 Posts

Posted - 2012-05-06 : 23:07:33
well my teacher told me to use timediff function for mysql

regardless, even using datediff and top returns the same exact syntax error:

Records: in 0.0003 sec
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '17:22:00, reg.registrationDateTime) from reg order by registrationDateTi' at line 1
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-06 : 23:11:48
quote:
Originally posted by PrequelToTheSQL

well my teacher told me to use timediff function for mysql

regardless, even using datediff and top returns the same exact syntax error:

Records: in 0.0003 sec
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '17:22:00, reg.registrationDateTime) from reg order by registrationDateTi' at line 1


As expected you're using mysql which is another dbms
This is ms sql server forum and people here are mostly familiar with only t-sql.
So please post in some mysql forums for getting mysql related help

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -