How to separate Date in query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yosiro
    New Member
    • Aug 2012
    • 34

    #1

    How to separate Date in query?

    I want to seperate date on query field.
    Eg. in the field date show 12/3/2012
    so i want to seperate just year in a new field

    in excel we known MID LEFT RIGHT function
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    If the date 12/3/2012 is in a field called DateField, then you would have the following in your query:

    Code:
    Year(DateField) AS YearField
    You can do the same thing with Month() and Day().

    Note: Don't name a field Year, Month, or Day, or Date even as an alias (the part after the AS) as these are reserved names and can cause problems when trying to reference them. Hence, my naming it DateField and YearField. You can can change the alias to be more descriptive for its use.
    Last edited by Seth Schrock; Sep 21 '12, 03:22 AM. Reason: Added note

    Comment

    Working...