Page 1 of 3 123 LastLast
Results 1 to 15 of 39
  1. #1
    bigroo's Avatar
    bigroo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2012
    Location
    Austin, Texas
    Posts
    101

    Extract Date

    Hello and Happy Thanksgiving to our US Readers.



    Here is my issue.

    Date Started Details
    01/01/1900 Silent from Black Gospel 5/19/2003
    01/01/1900 Oldies from Adult Stand. 11/1/2007
    01/01/1900 Format
    01/01/1900 Amistad Communications from Greenwood Acres Baptist Church 3/8/2006
    01/01/1900 Robert J. and Mary J.E. Whitaker, LLC from Amistad Communications 7/9/2010
    01/01/1900 Owner
    What I would like to do is cleanup this table using a query. Is there a way to extract the date where there is one from the end of the details field and insert the Date extracted nto the Date started field, I have approx 100,000 rows.

    Any guidance or help would be appreciated.

    Thanks

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    It looks to me like the [Date Started] field is a String field as well. Is that true?

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    This query may get you started. This will get the valid dates from the details field.

    Code:
    SELECT Bigroo.Details,
    Mid([dETAILS],InStrRev([Details]," ")+1,Len([Details])-InStrRev([Details]," ")) AS x,
     FROM Bigroo
    WHERE (((IsDate(Mid([dETAILS],InStrRev([Details]," ")+1,Len([Details])-InStrRev([Details]," "))))=True));
    Result based on your data

    Details x
    Silent from Black Gospel 5/19/2003 5/19/2003
    Oldies from Adult Stand. 11/1/2007 11/1/2007
    Amistad Communications from Greenwood Acres Baptist Church 3/8/2006 3/8/2006
    Robert J. and Mary J.E. Whitaker, LLC from Amistad Communications 7/9/2010 7/9/2010

  4. #4
    bigroo's Avatar
    bigroo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2012
    Location
    Austin, Texas
    Posts
    101
    Hi RuralGuy,
    No, [Date Started] is a Date field

    Thanks

  5. #5
    bigroo's Avatar
    bigroo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2012
    Location
    Austin, Texas
    Posts
    101
    Thanks Orange,

    Here is what I have, but I get an error message when I try to run.

    SELECT tblFacHistory.Details,
    Mid([Details],InStrRev([Details]," ")+1,Len([Details])-InStrRev([Details]," ")) AS x,
    FROM tblFacHistory,
    WHERE (((IsDate(Mid([Details],InStrRev([Details]," ")+1,Len([Details])-InStrRev([Details]," "))))=True));
    "The Select statement includes a reserved word or argument name that is misspelled or missing, or the punctuation is incorrect"

    I looked at the SQL statement and looks find.

    Thanks

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Here's a Public Function for a Standard Module that could then be used like:

    Set [Date Started] = GetDate([Details])

    Code:
    Public Function GetDate(InVal As String) As Date
    ' Return the date on the end of the Incoming String
    ' ie: "Oldies from Adult Stand. 11/1/2007"
       Dim InDate As String
       InDate = Mid(InVal, InStrRev(InVal, " "))
       If IsDate(InDate) Then
          GetDate = DateValue(InDate)
       Else
          GetDate = DateValue("1/1/1900")
       End If
    End Function

  7. #7
    bigroo's Avatar
    bigroo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2012
    Location
    Austin, Texas
    Posts
    101
    Thanks RuralGuy,

    I seem to have #Name? in the Date Started field now. I checked the spelling of names and all looks good.
    I have this as the form Control Source Set[Date Started]=GetDate([Details]) entered in the date started field. This is where it is to godd correct?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You would need to use it in an Update query.

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You have an extra comma after the tablename and after the x. These should both be removed.

  10. #10
    bigroo's Avatar
    bigroo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2012
    Location
    Austin, Texas
    Posts
    101
    Hi Rural Guy, thanks for your patiance.
    I am still having issues getting this to work. I created an update query with Date Started and Details in the grid from tblfachistory table. Under the Date Started update to row I enter Set[Date Started]=GetDate([Details]) but it will not accept this it changes it expression to this "Set[Date Started]"=GetDate([Details])
    I have error message as "Undefined Function 'GetDate' in Expression

  11. #11
    bigroo's Avatar
    bigroo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2012
    Location
    Austin, Texas
    Posts
    101
    Hi Orange, thanks for your patiance.

    Still no luck in getting the SQL statement to run either, still receiving the same error

  12. #12
    bigroo's Avatar
    bigroo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2012
    Location
    Austin, Texas
    Posts
    101
    Hello all,

    I am in the process of uploading a sample of the database, just stripping it down from 114mb.

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    The easiest way to strip down a db is to *import* it into a new fresh db and only select what you need.

  14. #14
    bigroo's Avatar
    bigroo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2012
    Location
    Austin, Texas
    Posts
    101
    Here is the database stripped down.
    Maybe you can see what I am doing wrong!
    Attached Files Attached Files

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    To start, you cannot name the Standard Module the same as the procedure it contains; or any other procedure for that matter.

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. how to extract month and year from date column
    By penguinwebsoft in forum Queries
    Replies: 5
    Last Post: 10-11-2012, 11:29 PM
  2. extract something from a field
    By tozey in forum Queries
    Replies: 4
    Last Post: 02-24-2012, 08:54 AM
  3. Query to extract maximum figures for each date
    By vijanand1279 in forum Queries
    Replies: 2
    Last Post: 11-03-2011, 10:41 PM
  4. Extract two last recodes
    By yosik20 in forum Queries
    Replies: 4
    Last Post: 04-12-2011, 01:35 PM
  5. Extract Creation/Last Edit Date
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 02-15-2011, 07:12 AM

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