How to display Current Year in formula WITH dates that are blank

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anoble1
    New Member
    • Jul 2008
    • 246

    How to display Current Year in formula WITH dates that are blank

    Hi,

    I have a problem that I cannot figure out. I have a query that I am working on. It includes dates mm/dd/yyyy in a column. I want to just show the current year like this:
    Code:
    =Year(Now())
    The query will not produce any results when I run it. I think the reason is because I have a few columns in their that the date field is blank. Before, I was searching with the criteria:
    Code:
    IS NOT NULL
    My question is, how do I put in the query, like this?
    Code:
    IS NOT NULL & Year(Now())
    Thanks,
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    This doesn't make good sense I'm afraid. I can't tell how much confusion is simply the wording of the question and how much is related to Access understanding (or lack of).

    Perhaps you can clarify what you're actually asking for help with. Don't be afraid to use more detail or example data (or even your current SQL - a sanitised version if it's overly complicated).

    Comment

    • anoble1
      New Member
      • Jul 2008
      • 246

      #3
      When I try to run the query with just using the
      Code:
      Year(Now())
      which just displays this year correct? It comes up with no data. The reason is, is because I have a column of dates that contain blank dates (nothing is in there). How do I use the Year(Now()) formula, when my data is mixed between null dates, and **/**/**** dates?

      Check it out.

      Store your photos and videos online with secure storage from Photobucket. Available on iOS, Android and desktop. Securely backup your memories and sign up today!
      Last edited by NeoPa; Aug 25 '11, 03:05 PM. Reason: Made picture visible in post (tried - but no go as the PhotoBucket link is not to the JPEG file)

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        With so little information still I'll just have to guess what you're talking about and you can tell me if I'm anywhere near the mark.

        It seems like you're trying to return a value of the current year (either numeric or string data) in a field which is a date by design. This is unlikely to make much sense, but it is conceivable so I'll have to allow you to make that judgement. Assuming that is (still) what you want to do then I suggest you convert the value into a string - otherwise the formatting of the field is likely to treat the numeric value as a date and you'll get something weird (quite different from what you want to see).

        The formula for the query field would be something like :
        Code:
        Nz([DateField], CStr(Year(Date())))

        Comment

        Working...