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
 Extracting a Date from a table

Author  Topic 

Stevanicus
Starting Member

1 Post

Posted - 2007-10-13 : 18:44:31
Hi, im currently learning sql. I have a problem extracting a date from a table.

SELECT Date FROM Flight

Gives me a "syntax error in sql expression"

in the table the date coloum - fields are set Date/Time

an example field is 28.12.2007 00:00

Thanks in advanced!

Steve

p.s. im using openoffice base, if i force to run the code it display's the date. however I would like it to run without errors. Thanks again

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-10-13 : 20:55:20
Is it for sql server? What's data type of the column? If it's datetime column, you can get date with this:

select convert(char(10), col_name) from tab_name
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-14 : 00:45:39
Maybe because DATE is a reserved word, try:

SELECT [red][[red]Date[red]][red] FROM Flight
SELECT [Date] FROM Flight

Edit: Thanks khTan

Kristen
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-14 : 03:32:05
Kristen missed out the '/' for the forum formatting code. It should be
SELECT [Date] FROM Flight



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-15 : 03:14:52
quote:
Originally posted by Stevanicus

Hi, im currently learning sql. I have a problem extracting a date from a table.

SELECT Date FROM Flight

Gives me a "syntax error in sql expression"

in the table the date coloum - fields are set Date/Time

an example field is 28.12.2007 00:00

Thanks in advanced!

Steve

p.s. im using openoffice base, if i force to run the code it display's the date. however I would like it to run without errors. Thanks again


Are you using Microsoft SQL Server?

If you are a newbie to sql, learn it

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -