By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,331 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,331 IT Pros & Developers. It's quick & easy.

Erasing part of a text string

P: 34
Hi,

I need to convert a text field into a number in order to perform calculation with it. However the data in the field has characters in like this:

24 hrs
3456 hrs
48 hrs
etc.

Is there any way of writing a query which removes the 'hrs' from every record ?
May 23 '07 #1
Share this Question
Share on Google+
2 Replies

missinglinq
Expert 2.5K+
P: 3,532
Why not simply use val(HoursField)?
May 23 '07 #2

P: 34
Why not simply use val(HoursField)?
Thanks Missinglinq, that a lot easier than the way someone else has just suggested.

(Add a new filed to your table defined as a number

Create a new query, without adding any tables.
Click on the SQL button & paste the following SQL in (amended with the correct details)

UPDATE TABLENAME SET TABLENAME.[NEW FIELD NAME] = Left([CURRENT FIELD NAME],Len([CURRENT FIELD NAME])-3);

run the query)
May 23 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.