SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 someone please help me with this query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

PrequelToTheSQL
Starting Member

2 Posts

Posted - 05/06/2012 :  22:24:11  Show Profile  Reply with Quote
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

India
48087 Posts

Posted - 05/06/2012 :  22:50:55  Show Profile  Reply with Quote
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 - 05/06/2012 :  23:07:33  Show Profile  Reply with Quote
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

Edited by - PrequelToTheSQL on 05/06/2012 23:08:28
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
48087 Posts

Posted - 05/06/2012 :  23:11:48  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000