Skip to main content
November 7, 2006
Answered

Partial Field Content Extract

  • November 7, 2006
  • 5 replies
  • 605 views
I have a field that is 20 Positions long.

I need to extract the first 8 positions and place into new field.

I need to extract positions 9 - 14 and place into another new field.

How do I accomplish this?

thanks
Ron
This topic has been closed for replies.
Correct answer
Hi Ron,
Just use Left for the first part, and Mid and Lenght for the second part.
Please refer to the documentation for more information.

Hope this helps,
Chris

5 replies

Correct answer
November 7, 2006
Hi Ron,
Just use Left for the first part, and Mid and Lenght for the second part.
Please refer to the documentation for more information.

Hope this helps,
Chris
Inspiring
November 7, 2006
He means do something like this:

<cfquery name="q">
select yourfield
from yourtable

Then
<cfoutput query="q">
#left(yourfield, 8)#
etc

ps, my syntax may be wrong
Participating Frequently
November 7, 2006
I've run into similar things. If you can't find any SQL functions that work with MS-Access, then just select the column as-is and do the conversions via CF using createDate(), createTime() and mid() to make the data look like what you want.

November 7, 2006
I am sorry, I guess this is my day to be really SLOW. I just don't understand your answer and am sure your are correct, I just don't understand. I have read about MID() and just seems to count characters. I don't see how to pick the positions 1-8 and 9-14 from my 20 position field that is not a valid date field.

Please expand on your answer.

Thanks
Ron
November 7, 2006
Dan

I don't really need two new fields. The first eight positions of the 20 position field is really yyyymmdd and needs to formatted in a report as yyyy/mm/dd. Positions 9-14 is really hhmmss and needs to formatted on report as hh:mm:ss.

I am using Access 2003 and I don't see any string function that does what I need. Again, I am using a clients database and the field that I am dealing with is not a date/time field. The DateFormat function will not work and returns an error stating that the data is not a valid date field.

Thanks
Ron
Inspiring
November 7, 2006
Different databases have different string functions. You didn't specify your database.

Some db's have a function called substr. Let's say your's does. Given that you can do,

select substr(yourfield, 1, 8) as abc, substr(yourfield, 9, 6) as xyz
from yourtable

are you absolutely sure you need the 2 new fields?