Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query a date field for a particular month 2

Status
Not open for further replies.

mman74

MIS
Aug 10, 2001
36
0
0
HK
I have a table with a date field. The format is "01-Jan-03". How can I query the table for a particular month, say all January records?
Is it difficult? Do I need to create a dummy field equal to the date field but in string format? If so how do I do that? I can tell the user to input two date ranges but it seems rather long-winded.
Thank you.
 
Something like this...

SELECT *
FROM tblDate
WHERE DATEPART('m',tblDate.fldDate) = 3;

Selects all records for month = 3 (March)

There are two ways to write error-free programs; only the third one works.
 
something like
select * from <tblname> where datepart('m',<tblname>.<datefield>) = n
where n is the month number should do the trick
 
Thank you very much, flavioooo & GHolden! Works exactly as you said it would.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top