PC Review


Reply
Thread Tools Rate Thread

select by month in query

 
 
SlySi
Guest
Posts: n/a
 
      16th Feb 2004

This may be a simple query but I would appreciate any help possible.

I have a query that I would like to selct only dates in a certai
month. I know how to use a form to enter start dates and end dates an
then select the date field between 'start date' and 'end date'. Howeve
I would like the user to simply enter in a three letter code for th
month and the query to select all records within that month.

eg. entering 'jan' will select all dates between 1/1 and 31/1 of jan o
the current year.

Is this easy to do?

Thanks in advance

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      17th Feb 2004
On Mon, 16 Feb 2004 05:54:51 -0600, SlySi
<(E-Mail Removed)> wrote:

>
>This may be a simple query but I would appreciate any help possible.
>
>I have a query that I would like to selct only dates in a certain
>month. I know how to use a form to enter start dates and end dates and
>then select the date field between 'start date' and 'end date'. However
>I would like the user to simply enter in a three letter code for the
>month and the query to select all records within that month.
>
>eg. entering 'jan' will select all dates between 1/1 and 31/1 of jan of
>the current year.
>
>Is this easy to do?


Not too hard: a criterion of

>= CDate("1-" & [Enter month:] & "-" & Year(Date()) AND < DateAdd("m", 1, CDate("1-" & [Enter month:] & "-" & Year(Date()))


will do the trick. If your users can enter month numbers it's a bit
simpler using DateSerial():

>= DateSerial(Year(Date()), [Enter month number:], 1) AND < DateSerial(Year(Date()), [Enter month number:] + 1, 1)



John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
Reply With Quote
 
 
 
 
Sunny
Guest
Posts: n/a
 
      18th Feb 2004
You can also try

SELECT * FROM [your table name]
WHERE FORMAT([your date field],"mmm") = [given month]
"SlySi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> This may be a simple query but I would appreciate any help possible.
>
> I have a query that I would like to selct only dates in a certain
> month. I know how to use a form to enter start dates and end dates and
> then select the date field between 'start date' and 'end date'. However
> I would like the user to simply enter in a three letter code for the
> month and the query to select all records within that month.
>
> eg. entering 'jan' will select all dates between 1/1 and 31/1 of jan of
> the current year.
>
> Is this easy to do?
>
> Thanks in advance.
>
>
> ------------------------------------------------
> ~~ Message posted from http://www.ExcelTip.com/
> ~~View and post usenet messages directly from http://www.ExcelForum.com/
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avg. 1-month, 3-month, 6-month & 12-month Stock Returns ryguy7272 Microsoft Access Queries 2 7th Feb 2010 04:28 PM
Select all dates in month from month and year in text box? LeeZard via AccessMonster.com Microsoft Access Queries 1 3rd Mar 2008 05:38 PM
Tell me which "season" (Month/Day through Month/Day) a date(Month/Day/Year) falls in (any year)??? misscrf Microsoft Excel Misc 1 14th Dec 2007 03:59 PM
Print Current Month with last month and next month in Header JMoore0203 Microsoft Outlook Calendar 1 5th Dec 2007 05:15 PM
printing Little Current month and Little Next month on Banner when it should little PRIOR month and little Next month. jake_allen10@hotmail.com Microsoft Outlook 0 3rd Nov 2006 08:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:24 PM.