Results 1 to 5 of 5
  1. #1
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58

    Find and Replace Query

    I am using Access 2002 I am needing to create an update query that will find and replace in a field.

    Table Name: All
    Field Name: Date and Time

    Find 1/1/1900 12:00:00 AM in the Date and Time field and replace with a blank ("").



    I have tried multiple ways and can not seem to find a solution.

  2. #2
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58
    Here is what I have so far and it does not work correctly

    Code:
    SELECT Date_and_Time, Replace(Date_and_Time,"12:00:00 AM","") AS NewDate
    FROM Test;

    I have tried to include spaces inside of the replacement ("") and it enters a bunch of spaces in the field after the date.

  3. #3
    objNoob is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    21
    UPDATE tblTest SET Date_and_Time = Null
    WHERE Date_and_Time=CVDate(2);

    Access stores dates as Doubles.

    CVDate(2) is exactly 1/1/1900 12:00:00 AM

    Use CDbl(#1/1/1900 12:00:00 AM) to convert Date / Time to Double.

    CDble(x) Converts x to Double
    and CVDate(x) Converts double to Date

    I hope this helps!

  4. #4
    objNoob is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    21
    Quote Originally Posted by randolphoralph View Post
    Here is what I have so far and it does not work correctly

    Code:
    SELECT Date_and_Time, Replace(Date_and_Time,"12:00:00 AM","") AS NewDate
    FROM Test;

    I have tried to include spaces inside of the replacement ("") and it enters a bunch of spaces in the field after the date.
    This will not work if your column is of data type date/time, because a date/time cannot be an empty string. If your column allows NULL values, my suggested UPDATE should work given 1/1/1900 was the date you really needed to replace.

  5. #5
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58
    I have tried your recommendation and then realized that the field is set to Text as the Data Type. I have tried to change the Data Type to Date/Time and save the table I receive a error message stating "Microsoft Access can not change the data type there is not enough disk space or memory"

    So here is what I am needing to do for the Date and Time field.

    Here are items that are currently found in this field....
    1/1/1900 12:00:00 AM
    2/3/2009 12:00:00 AM (various dates)
    12:00:00 AM

    Here is what I need to do....

    replace all 1/1/1900 12:00:00 AM with a empty value
    remove 12:00:00 AM from 2/3/2009 12:00:00 AM (various dates)
    and replace 12:00:00 AM with a empty value

    Any help would be really appreciated.

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

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2012, 06:42 AM
  2. Query to find lowest value
    By AccessNubie in forum Access
    Replies: 3
    Last Post: 11-30-2009, 07:54 AM
  3. Use query to find and sum data
    By kwelch in forum Queries
    Replies: 3
    Last Post: 11-23-2009, 04:26 AM
  4. Applying a find/replace function
    By Arr in forum Programming
    Replies: 2
    Last Post: 10-12-2009, 12:28 PM
  5. replace characters in a string
    By blazixinfo@yahoo.com in forum Access
    Replies: 6
    Last Post: 08-06-2009, 03:36 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