473,626 Members | 3,675 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

update to parse out part of record

How can I write an update query that removes part of a field? Like if I
have a field with values such as 8/3/68 (a birthday obviously) and I need
to put values in a new column but I need everything after and including the
final / removed to end up with simply 8/3
Nov 12 '05 #1
3 4741
Ken,
Regardless of how the date is displayed, if the field is a Date/Time
datatype, the actual value is stored as a number.
Today's date, 9/10/2003, is stored as 37874.

Any valid date must include the month, day, and year values.
8/3 is NOT a valid date datetype.

There is no need for an update query.

To 'display' a date as 8/3 in a date field all you need do is set the
field's format property to
mm/dd

To do this in a query, you would use:
NewField:Format ([DateField],"mm/dd")

In a form or report control:
=Format([DateField],"mm/dd")
make sure the name of the control is not the same as [DateField].

Just show it as I have indicated above, in a form, report, or query.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Ken Bush" <KB****@csu.edu > wrote in message
news:hxK7b.4086 57$o%2.186111@s ccrnsc02...
How can I write an update query that removes part of a field? Like if I
have a field with values such as 8/3/68 (a birthday obviously) and I need
to put values in a new column but I need everything after and including the final / removed to end up with simply 8/3

Nov 12 '05 #2
Er.. that was just kind of an example, not to be taken literally as such.
I guess that's my fault.

Let me try again.

Field1 has values such as

10_51_ER

I need to update Field2 to everything but the last _ and whatever follows
it, for example in this case it would be 10_51. Note that the values of
field1 may have less or more underscore seperators, but in any case I need
the last one and what follow to be removed.

fg******@att.ne t (Fredg) wrote in
<t7************ **********@bgtn sc04-news.ops.worldn et.att.net>:
Ken,
Regardless of how the date is displayed, if the field is a Date/Time
datatype, the actual value is stored as a number.
Today's date, 9/10/2003, is stored as 37874.

Any valid date must include the month, day, and year values.
8/3 is NOT a valid date datetype.

There is no need for an update query.

To 'display' a date as 8/3 in a date field all you need do is set the
field's format property to
mm/dd

To do this in a query, you would use:
NewField:Forma t([DateField],"mm/dd")

In a form or report control:
=Format([DateField],"mm/dd")
make sure the name of the control is not the same as [DateField].

Just show it as I have indicated above, in a form, report, or query.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Ken Bush" <KB****@csu.edu > wrote in message
news:hxK7b.408 657$o%2.186111@ sccrnsc02...
How can I write an update query that removes part of a field? Like if
I have a field with values such as 8/3/68 (a birthday obviously) and I
need to put values in a new column but I need everything after and
including

the
final / removed to end up with simply 8/3



Nov 12 '05 #3
If I understand you correctly you want to use Field1's data (10_51_ER)
to parse into Field2 (as 10_51).

If the final underscore is ALWAYS followed by 2 letters:
Update YourTable Set YourTable.Field 2 = Left([Field1],len([Field1]-3))
Where [Field1] is not null;

However, if the characters after the final underscore can vary, (10_51_A or
10_51_ABCD),
AND you are using Access 2002 (or some versions of Access 2000) you can use:

UPDATE YourTable SET YourTable.Field 2 =
Left([Field1],InStrRev([Field1],"_")-1)
WHERE YourTable.Field 1) Is Not Null;

If you are using a previous version of Access (97, 95, 2) that does not have
the InStrRev() function, you'll need to write a user defined function to
find the final underscore position and return the wanted string.

Add the following function to a module:

Public Function Parse(strIn As String) As String
Dim intX As Integer
Dim intY As Integer
intX = InStr(strIn, "_")
If intX = 0 Then
Parse = strIn
Exit Function
Else
Do While intX <> 0
intY = intX + 1
intX = InStr(intY, strIn, "_")
Loop

Parse = Left(strIn, intY - 2)
End If

End Function
===

Then make an Update query:

Update YourTable Set YourTable.Field 2 = Parse([Field1])
Where Field1 is not null.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Ken Bush" <KB****@csu.edu > wrote in message
news:WiL7b.3093 40$cF.94367@rwc rnsc53...
Er.. that was just kind of an example, not to be taken literally as such.
I guess that's my fault.

Let me try again.

Field1 has values such as

10_51_ER

I need to update Field2 to everything but the last _ and whatever follows
it, for example in this case it would be 10_51. Note that the values of
field1 may have less or more underscore seperators, but in any case I need
the last one and what follow to be removed.

fg******@att.ne t (Fredg) wrote in
<t7************ **********@bgtn sc04-news.ops.worldn et.att.net>:
Ken,
Regardless of how the date is displayed, if the field is a Date/Time
datatype, the actual value is stored as a number.
Today's date, 9/10/2003, is stored as 37874.

Any valid date must include the month, day, and year values.
8/3 is NOT a valid date datetype.

There is no need for an update query.

To 'display' a date as 8/3 in a date field all you need do is set the
field's format property to
mm/dd

To do this in a query, you would use:
NewField:Forma t([DateField],"mm/dd")

In a form or report control:
=Format([DateField],"mm/dd")
make sure the name of the control is not the same as [DateField].

Just show it as I have indicated above, in a form, report, or query.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"Ken Bush" <KB****@csu.edu > wrote in message
news:hxK7b.408 657$o%2.186111@ sccrnsc02...
How can I write an update query that removes part of a field? Like if
I have a field with values such as 8/3/68 (a birthday obviously) and I
need to put values in a new column but I need everything after and
including

the
final / removed to end up with simply 8/3


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3340
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city city_id 1 john newyork null
1
1883
by: oldandgrey | last post by:
I'm looking at producing an application that will allow multiple users to order multiple items/ parts from what would effectively be an online store. These users could be ordering several hundred items/ parts at a time, each item/ part ordered representing one box or several hundred. Each part record will require the "total stock" to be down dated and each unit will require updated to show it as having been picked (plus other info).
1
2116
by: Rolan | last post by:
Having tried various permutations of Before Update and well for that matter, After Update, OnExit, OnEnter, etc. and also Locked controls, I'm still unable to obtain the intended results. There are actually two parts of what I'm trying to accomplish, but are interrelated. When one part performs as it should, then upon implementation of the other, conflicts arise and vice versa. A form (frmEvents) is used to logged various events and one...
4
2721
by: gj | last post by:
Hi, I'm trying to update a sql database from a web form using text boxes. I'm trying to learn C# on my own so I am at a complete loss. I created my sql connection, data adapter, dataset and data view in the visual studio designer. I'm trying to keep a history of the record so instead of editing the record I insert a new record with my changes. Instead of the changes, it inserts the orginal record. Below is the part of the code. Any help...
1
2020
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da browsers and click update it gave me this error: Specified argument was out of the range of valid values. Parameter name:
11
2236
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to reflect that the 3 items have been deleted only to discover that the 3 items appear, however when I click on them to display their information which runs a datareader over the same database it appears that the data has now gone. I wondered whether...
4
1913
by: UKuser | last post by:
Hi Guys, I am trying to create an editable table of a MySQL query where every field can be updated. My example script is at: http://nana46.coconia.net/test4.php however I am currently getting Parse errors. Am I missing anything obvious in my code below? Thanks
2
3100
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i havnt tested the index yet ) so you can use an .UPDATE( dataTable ) on the data adapter. Otherwise you will get an exception error. Is this statement true? ---- Now me fumbling thru
29
2884
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.