Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Need Help On SQL Syntax
fabiocardoso
post Aug 28 2005, 01:00 AM
Post #1


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 25
Joined: 7-August 05
Member No.: 7,682



How I make a query in SQL Server using a field of the type date?

Example: SELECT * FROM Customer WHERE Birth = ' 01/01/1982 '

I must use quotes marks same, or exists some another separator for the field of the type date?

This post has been edited by microscopic^earthling: Aug 28 2005, 02:53 AM
Go to the top of the page
 
+Quote Post
Houdini
post Aug 28 2005, 01:59 AM
Post #2


Super Member
Group Icon

Group: Members
Posts: 572
Joined: 25-April 05
From: Nashville Tennessee
Member No.: 4,340



What you have shown
QUOTE
SELECT * FROM Customer WHERE Birth = ' 01/01/1982 '


is a perfectly valid SQL query that tells the server to retrieve all people from the customer table whose birthday was on 01/01/1982, if there were none that met that criteria then the response would be blank or null becuse no record was found that met the criteria, just for the fun of it to make sure your syntax is right do this

CODE
SELECT * FROM Customer WHERE Birth = '*'


and it will return all customers just as if you did a

CODE
SELECT * FROM Customer

then you could also do this for age verification of those at least 22 years old by

CODE
SELECT * FROM Customer WHERE Birth >= ' 01/01/1982 '


Go to the top of the page
 
+Quote Post
yordan
post Aug 28 2005, 12:18 PM
Post #3


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 2,242
Joined: 16-August 05
Member No.: 7,896
myCENTs:44.47



And also, look what is your database, by simply writing
select Birth from customer ;
this will tell you all the birth dates in your database, and you will see whether you had blanks, or wich format your customers used.
this is not very different from "select * from customer", but will give you only the Birth column, this should be nicer for diagnostics.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Sql Syntax Error [corrected](2)


 



- Lo-Fi Version Time is now: 4th December 2008 - 11:23 PM