Results 1 to 9 of 9
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    concatination with cdate

    Hi

    just spent some time visiting casual dating sites - not a good idea;-)

    OK I have three fields all text and I want to concatenate them into a single field and convert them to a date format so I can sort ascending

    So I know that cdate is the way to go and that the & is used to concatenate.

    I seem unable to find out how to use cdate to do this on the web hence my visits to funny web sites.

    I assume I do it as an expression in a query? and not at table level?



    as usual any help appreciated

    thanks

    Ian

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Code:
    Dim strDate As String
    Dim aDate As Date
    strDate = "Apr 26, 2016" 
    aDate = CDate(strDate)
    function CDate will convert any string with a valid date to a date data type.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Depending on what the fields contain, DateSerial() may be a better option. I suspect what you were looking for:

    CDate(month & "/" & day & "/" & year)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    thanks for that.

    I do seem to having trouble in getting my head around the intricacies of modules, VBA and macros. I think I've cracked macros but the other two are defying my addles brain.

    I follow the code you suggested but how do I implement it?

    ie in a query do i add

    Code:
    fulldate:CDate(month & "/" & day & "/" & year)
    so it's an expression?

    or do I ....

    Sorry must seem stupid but I'm not getting anywhere

    thanks

    Ian

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That should work, using your actual field names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    invalid

    Hi

    twas me being less than ........

    I tried the code again and realised that

    Code:
    FullDateofBurial:CDate(DayOfBurial & "/" & MonthOfBurial & "/" & YearOfBurial)
    did work. What confused me was that some of the records do not have an entry for DayofBurial, MonthofBurial and YearofBurial

    hence the expression brings me a displayed value of #Error in some records

    How do I add a criteria only to display the results if the result is viable

    as always thanks

    Ian

  7. #7
    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 could add

    Is Not Null

    to the criteria for all 3 fields.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Thanks I'll try it but I have no doubt you are correct!! I did try "" but not Is Not Null

    cheers

    Ian

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

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

Similar Threads

  1. concatination issue
    By Jen0dorf in forum Access
    Replies: 6
    Last Post: 04-05-2016, 06:08 AM
  2. writing a concatination field
    By Jen0dorf in forum Access
    Replies: 5
    Last Post: 03-30-2016, 10:48 AM
  3. Use Cdate and write yesterday's date?
    By Elin in forum Programming
    Replies: 4
    Last Post: 09-18-2014, 03:30 AM
  4. what does this mean: [classes]![cDate]
    By rankhornjp in forum Programming
    Replies: 6
    Last Post: 11-09-2011, 02:37 PM
  5. CDate in my append query
    By Steven.Allman in forum Queries
    Replies: 3
    Last Post: 04-11-2011, 01:00 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