Results 1 to 3 of 3

Thread: [RESOLVED] How to determine if year is current

  1. #1

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Resolved [RESOLVED] How to determine if year is current

    Hi,

    how do i filter the dates in the table using a query that will only display dates corresonding to the current year...

    Assuming that the table has dates from 2000-2008..When I run the program, it will display the all dates in the gridview with year 2008...


    Whats the date function to do this?

    Whats a function to display if the month is also current?


    using sql server 2005..

    Table name:

    Calendar
    fields:
    CalendarDate (datetime)
    CalendarIsCurrentDate (bit)
    CalendarWorkingDayType (varchar(50))
    Utilized(bit)


    thnx
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  2. #2
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: How to determine if year is current

    you can use

    WHERE YEAR(CalendarDate ) = 2008
    __________________
    Rate the posts that helped you

  3. #3
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: How to determine if year is current

    if you dont want to pass parameter you can use

    Code:
    select *
    FROM  Calendar
    WHERE YEAR(CalendarDate ) = YEAR(GetDate()) AND  MONTH(CalendarDate ) = MONTH(GetDate())
    __________________
    Rate the posts that helped 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