Hello Experts:
In a previous thread (Need to trim *all fields* across *all tables* (accessforums.net) -- post #49), I received some wonderful assistance from forum expert @darkwind. With the help of darkwind, we established routine which does the following:
1. Function reads-in a date-time value (stored as *short text*) and converts it into a date-time data type.
2. As part of this routine, it also strips out the "milli-seconds" and places them into a numeric field.
Example (before):
- Short Text = "2018/10/29 14:08:06:112"
Example (after):
- Date/Time = "2018/10/29 14:08:06"
- Number = "112"
Again, the function (which is not included in the sample DB) works really well with my sample data. However, once I applied it to my actual data (thousands of records), I have noticed an issue w/ a sub-set of the underlying data (not the function).
I'll summarize the *data* issue below:
- Attached DB includes 2 tables each of them containing a single field [FIELD2].
- Both tables contain date-time related content but (again) these are stored in "Short Text" data format.
- While [Table1] is "clean" (so to speak), [Table2] contains some erroneous dates... these are a non-issue while in string format. However, they turn out to be an issue when running the function.
- Specifically, the 2nd record in [Table2] = "2019/10/26 24:54:30:949".
- Well, there is no such things as hh/nn being equal to "24:54". It would be either "23:54" or "00:54" (aka 12:54 AM).
- Note: I am NOT the data owner so I cannot speak as to how this happened in the source system.
What I need some assistance with:
========================
- Develop a method (query or VBA) which -- before running my function -- would identify & clean any erroneous hh:nn (while still being in *string* format).
Business Rule:
- Scan through all tables that have an "801_" prefix.
- Next, although my actual tables have more than a single field, parse through only [FIELD2] and
- ... where any hh:nn value is >= 24:00 (e.g., "24:01" or "24:59") then
- change the string value day by adding 1 to the day AND subtracting "24" from the hour value.
- For instance, erroneous value = "2019/10/26 24:54:30:949" should change to string value "2019/10/27 00:54:30:949"
- The latter, however, would be inconsistent in the event the erroneous string value = 10/31/2022 24:01 since there's no such thing as "10/32/2022 00:01".
The above business rule is only meant to be a conceptual scenario. There may be a much easier way to do this. But do keep in mind that no arithmetic can be done w/ the [FIELD2] given it must stay "short text" (for now). The conversion into an actual date will occur w/ my existing function.
Any thoughts on how to clean up the erroneous hh:nn into an acceptable format so that my existing function won't fail during the conversion process?
Thank you,
Tom