Results 1 to 9 of 9
  1. #1
    dummy is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    4

    Date

    Hi there!



    I'm stuck!

    How can I change a date format yyyymmdd text format into a yyyy-mm-dd or dd-mm-yyyy format?

    Also how can I run a query to counts a period of time in between dates?

    Thanks a lot!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can use the DateSerial() function, along with the Mid() function to pull out each of the appropriate parts. You can use the DateDiff() function to calculate an interval between two dates. More info on all these functions in Help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dummy is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    4

    Thanks!

    I will try it!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem; post back if you get stuck. Welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    dummy is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    4

    Thumbs up date

    I am still stuck on this...
    the situation:

    ID Name PostCode DateOfBirth ShoppingCategory ShoppingCatergory1 ShoppingDate (and lots of other fields, that don't really matter)

    the problem is that: date of birth and shoppingdate come up as yyyymmdd (and some times incomplete or 0000mmdd, yyyy00dd, yyyymm00 or even 00000000) and also this has to be fixed to a standard parameter that we have.

    If I use design view it does not accept to change into a date/time format...

    I need to have this as dd-mm-yyyy view.

    And, How can I find out the age of the person when shopping a product?

    I know that I asked many things, but I really would be happy with some help!

    xx

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I've been on vacation; did you sort this out? How do you expect to calculate an age when records might not have the birth date?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    dummy is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    4
    Not really.

    and I will have to 'set' a date for those that have a incomplete date or ignore them.

    by the way: can I set a date automatically for those with invalid date?

    Many thanks

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    set invalid date to null:
    update tbl set strdate=null where mid(strdate,1,4)="0000" or mid(strdate,5,2)="00" or mid(strdate,7,2)="00"

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I imagine you would test for "00" or "0000" as appropriate, and replace with whatever you want the default to be. I might use different methods depending on whether you were doing this on the fly or fixing bad data permanently.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 07-07-2010, 04:22 PM
  2. Set date field on subform to date variable
    By laavista in forum Access
    Replies: 4
    Last Post: 06-30-2010, 06:32 PM
  3. set date field on form to date variable
    By laavista in forum Access
    Replies: 3
    Last Post: 06-28-2010, 03:03 AM
  4. Replies: 2
    Last Post: 07-31-2009, 06:56 AM
  5. Replies: 1
    Last Post: 12-09-2005, 10:29 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