Results 1 to 10 of 10
  1. #1
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89

    Date dfference +4 years


    Quick question, hoping you may be able to help with, I have a date issed (1/1/12), what I am trying to do is run a count query (4 years max), is this possible or is there a better way to do this

    thanks for your help
    novice

  2. #2
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    Date dfference +4 years

    DateAdd ( interval, number, date )

    DateAdd ("m", 4, #20/11/2013#)

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Alex, that is months and not MS formatted date.

    For the 4 years prior to current date.

    IssueDate > DateAdd("yyyy", -4, Date())
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    Date dfference +4 years

    Doh! It's not even a minus, don't know where my head was at!

    Corrected:
    DateAdd ("yyyy", -4, DateValue)

    Originally posted which was incorrect:
    DateAdd ("y", -4, DateValue)
    Last edited by AlexHedley; 11-20-2013 at 11:38 PM.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Don't know why, but single "y" doesn't work. The function will default to "d" unit. Have to use "yyyy".
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Perhaps this can also help clear thing up, the following identifies characters you can use to create user-defined date/time formats:

    c Display the date as ddddd and display the time as ttttt, in that order. Display only date information if there is no fractional part to the date serial number; display only time information if there is no integer portion.
    d Display the day as a number without a leading zero (1 – 31).
    dd Display the day as a number with a leading zero (01 – 31).
    ddd Display the day as an abbreviation (Sun – Sat).
    dddd Display the day as a full name (Sunday – Saturday).
    ddddd Display the date as a complete date (including day, month, and year), formatted according to your system's short date format setting. The default short date format is m/d/yy.
    dddddd Display a date serial number as a complete date (including day, month, and year) formatted according to the long date setting recognized by your system. The default long date format is mmmm dd, yyyy.
    w Display the day of the week as a number (1 for Sunday through 7 for Saturday).
    ww Display the week of the year as a number (1 – 54).
    m Display the month as a number without a leading zero (1 – 12). If m immediately follows h or hh, the minute rather than the month is displayed.
    mm Display the month as a number with a leading zero (01 – 12). If m immediately follows h or hh, the minute rather than the month is displayed.
    mmm Display the month as an abbreviation (Jan – Dec).
    mmmm Display the month as a full month name (January – December).
    q Display the quarter of the year as a number (1 – 4).
    y Display the day of the year as a number (1 – 366).
    yy Display the year as a 2-digit number (00 – 99).
    yyyy Display the year as a 4-digit number (100 – 9999).
    h Display the hour as a number without leading zeros (0 – 23).
    Hh Display the hour as a number with leading zeros (00 – 23).
    N Display the minute as a number without leading zeros (0 – 59).
    Nn Display the minute as a number with leading zeros (00 – 59).
    S Display the second as a number without leading zeros (0 – 59).
    Ss Display the second as a number with leading zeros (00 – 59).
    t t t t t Display a time as a complete time (including hour, minute, and second), formatted using the time separator defined by the time format recognized by your system. A leading zero is displayed if the leading zero option is selected and the time is before 10:00 A.M. or P.M. The default time format is h:mm:ss.
    AM/PM Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M.
    am/pm Use the 12-hour clock and display a lowercase AM with any hour before noon; display a lowercase PM with any hour between noon and 11:59 P.M.
    A/P Use the 12-hour clock and display an uppercase A with any hour before noon; display an uppercase P with any hour between noon and 11:59 P.M.
    a/p Use the 12-hour clock and display a lowercase A with any hour before noon; display a lowercase P with any hour between noon and 11:59 P.M.
    AMPM Use the 12-hour clock and display the AM string literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. The default format is AM/PM.


    Reference Link : http://msdn.microsoft.com/en-us/libr.../gg251755.aspx

    Hope this help shed some light on the different formats.

    Naeem~








  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That's for formatting a date value, which results in a text string value. DateAdd doesn't work with all those parameters as you might think - as seen with "y" and "yyyy".
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Got it. I just wanted to provide additional resource to help identify all options of formatting. Thank you for clearing that up, definitely not my intention to help confuse. We have enough confusion without help.. lol.

    Naeem~

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Thanks, Naeem, it was good-to-know info, just not directly related to the issue.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    Date dfference +4 years

    I should just write off my answer today, sorry about that, thanks for correcting me


    Quick Ref Table:

    ValueExplanation
    yyyy Year
    q Quarter
    m Month
    y Day of the year
    d Day
    w Weekday
    ww Week
    h Hour
    n Minute
    s Second

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Crosstab query with date range (2 years)
    By Cassim in forum Queries
    Replies: 7
    Last Post: 11-11-2013, 08:48 AM
  2. fiancial years
    By Compufreak in forum SQL Server
    Replies: 4
    Last Post: 05-10-2013, 12:12 AM
  3. Select changes in the years
    By acs_one in forum Queries
    Replies: 8
    Last Post: 11-27-2010, 05:26 PM
  4. Replies: 1
    Last Post: 11-12-2010, 01:16 AM
  5. query date that is five years older than today
    By cpsummer in forum Queries
    Replies: 2
    Last Post: 09-26-2007, 02:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums