Results 1 to 5 of 5

Thread: [RESOLVED] select based on month in date field

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Posts
    83

    Resolved [RESOLVED] select based on month in date field

    Hi,

    I want to select a range of information from a table using the date field, that is using the month. For example I need to be able to select all records for a particular month using the date field. My date field is of the format dd/mm/yyyy in the table.

    Could someone help me please.

  2. #2
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    396

    Re: select based on month in date field

    Hi sunshine123;

    What database are you using?

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: select based on month in date field

    Not at work, but a couple options come to mind. You could get the month using Month(somedate), using Mid(somedate, 4, 2), etc.
    Code:
    SELECT tblFoo.fldBar FROM tblFoo
    WHERE Month(tblFoo.fldDate) = 04
    .
    .
    SELECT tblFoo.fldBar FROM tblFoo
    WHERE Mid(tblFoo.fldDate, 4, 2) = 04
    Might be off a bit on syntax, but something like this.
    Tengo mas preguntas que contestas

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Posts
    83

    Re: select based on month in date field

    Hi there,

    yep you are right. I tried it and it worked. Thanks so much.

    I have one more problem...regarding date with the database though I'm not sure whether this should be posted in this section of the forum cos it involves c# datetime picker. I think I'll better post it there.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: select based on month in date field

    Quote Originally Posted by sunshine123
    ...cos it involves c# datetime picker. I think I'll better post it there.
    That would be appropriate.

    If you consider this resolved, would you please pull down the Thread Tools menu and click the Mark Thread Resolved menu item? That will let everyone know that you have your answer.

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width