Skip to main content
Inspiring
March 15, 2012
Answered

Display Date Only - By Year

  • March 15, 2012
  • 1 reply
  • 1215 views

This is probably simple but I can't find a solution...

Maybe brain not in right place...

I have multiple dates... ie data entry on different dates...

And want to search these entries... And display only the year...

ie... Data entered in 2011 and 2012...

Want to display output of "2011" and "2012" to break down the dates...

cfquery name="staty" datasource="fpb">

select * from inspid

where inspectorid = #session.inspuser_id#

order by inspdate desc

cfquery>

Output - just the years - from multiple dates...

Seems simple - but I can't get it in my head...

Thx

    This topic has been closed for replies.
    Correct answer Merle_Hanson

    "I can't find a solution" - How hard have you tried? Try Googling [...]

    Wow.  Didn't know you could do that.

    --

    Adam


    Thanx for the sarcasim...

    Yes I consider google my textbook...

    Answer here...

    <cfquery name="staty" datasource="fpb">

    select distinct year(inspdate) AS yydate from inspid

    where inspectorid = #session.inspuser_id#

    </cfquery>

    <cfoutput query=staty>

    #yydate#

    </cfoutput>

    Coding was blurred in my head...

    1 reply

    Inspiring
    March 15, 2012

    The way to select just the year portion of a date field depends on the type of db you are using.

    Inspiring
    March 15, 2012

    Using MS Access

    Owainnorth
    Inspiring
    March 15, 2012

    Seriously, what's with all the people using Access lately? They giving away licences with Happy Meals or something?

    "I can't find a solution" - How hard have you tried? Try Googling "Access date functions" - ah, there's a year() function. I wonder what that does...

    Oh, and don't do "select *".