dbTalk Databases Forums  

[sql-general] newbie question

mailing.database.sql-general mailing.database.sql-general


Discuss [sql-general] newbie question in the mailing.database.sql-general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kchan_bs
 
Posts: n/a

Default [sql-general] newbie question - 12-11-2005 , 06:14 PM






Hi All,

I have an employee table:

id
name
hiredate

My question is how I would find all the people that were hired within
the current year?

Thanks.





------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQ...wFAA/PhFolB/TM
--------------------------------------------------------------------~->

Subscribe: sql-general-subscribe (AT) yahoogroups (DOT) com
Unsubscribe: sql-general-unsubscribe (AT) yahoogroups (DOT) com
List owner: sql-general-owner (AT) yahoogroups (DOT) com
URL: http://groups.yahoo.com/group/sql-general
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sql-general/

<*> To unsubscribe from this group, send an email to:
sql-general-unsubscribe (AT) yahoogroups (DOT) com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/







Reply With Quote
  #2  
Old   
undercups
 
Posts: n/a

Default Re: newbie question - 01-08-2006 , 09:32 AM






This will do the trick

SELECT id, name FROM employee
WHERE hiredate > BETWEEN '1 Jan 2005 00:00:00' AND '31 Dec 2005
23:59:59'

Note that I have added the time to the dates especially 31 Dec as the
default time is taken as 00:00:00 i.e. the start of the day. It also
makes is very obvious what you intended.

Hope this helps


Duncan


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.