473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Splitting a Filed/Column

peeaurjee
Hi!
I have a column in the Table of my database named 'Duration of Labour Contract' and inside this i have entered the data like that:

01/01/2006 - 31/12/2009

Now i need to split this column into two, in which one should be named 'dlcfrom' and 'dlcto' by isolating the two dates. On the form it should look like that:
From : 01/01/2006 To: 31/12/2009

So is it possible to split a column into two or I will do it manually by cutting and pasting and editing the whole 1200 records :( any other solution please if is it there.
Dec 11 '07 #1
9 1538
hjozinovic
167 100+
Hi there!
Don't worry, I solved this problem and attached the database to this reply so you can see how it's done.
I copy/pasted your date range and did the split.

Note that ContractStart and ContractEnd fields are Date/Time type, while your data range is Text!
All you need to do is to make an Update query like i did and find a way to run it (I added a button for that).

Importaint: You must check that all your original entries are entered in the same way and text length with the spaces around "-" !!!
(01/01/2006 - 31/12/2008)

Best, H.
Dec 11 '07 #2
hi friend!

Thank you very much but i still don't have any idea what you've done and also i am seeing no attachment. Where did you attach the sample data base?
Dec 11 '07 #3
hjozinovic
167 100+
Hi
Sorry I havent attached the database before...
Here it is...
Attached Files
File Type: zip Splitting.zip (17.8 KB, 93 views)
Dec 11 '07 #4
missinglinq
3,532 Expert 2GB
(1) The easiest way to do this, to my mind, would be to use calculated fields in a query, then base your form on the query. This is always the preferred method, rather than basing the form directly on the table. If you've already done this, skip to Step # 3.

(2) If you haven't already done this, simply use the query wizard and include all fields from the table. Now go into Design View for your form and change the RecordSource from your table to your query.

(3) Go into Design View for your new query. In a blank "Field" box enter:
Expand|Select|Wrap|Line Numbers
  1. dlcfrom: Left([YourCombinedDatesField],instr([YourCombinedDatesField], " ")-1)
(4) Repeat this with a new blank field and enter:
Expand|Select|Wrap|Line Numbers
  1. dlcto: Right([YourCombinedDatesField],InstrRev([YourCombinedDatesField], " ")-3)
(5) Now on your form or in reports you can simple refer to these two fields as if they actually existed in your table.

For you appearance on you form you could use something like:

Expand|Select|Wrap|Line Numbers
  1. Me.DisplayDates = "From: " & Me.dlcfrom & : To: " & dlcto
Note that in this method the only requirements is that the original field has at least one space after the first "date" and at least one space before the second "date."

Linq ;0)>
Dec 11 '07 #5
Hi
Sorry I havent attached the database before...
Here it is...
Oh Thank You very very much. It was really helpful and it did work for me. The only thing i did different is that i kept the Data Type of the ContractStart and ContractEnd as Text because most of the fields are also in the following format.

ContractDuration: 01/01/2007 - Unlimited

Thus i got the same result i wanted. Thanks to you once again.
Dec 11 '07 #6
(1) The easiest way to do this, to my mind, would be to use calculated fields in a query, then base your form on the query. This is always the preferred method, rather than basing the form directly on the table. If you've already done this, skip to Step # 3.

(2) If you haven't already done this, simply use the query wizard and include all fields from the table. Now go into Design View for your form and change the RecordSource from your table to your query.

(3) Go into Design View for your new query. In a blank "Field" box enter:
Expand|Select|Wrap|Line Numbers
  1. dlcfrom: Left([YourCombinedDatesField],instr([YourCombinedDatesField], " ")-1)
(4) Repeat this with a new blank field and enter:
Expand|Select|Wrap|Line Numbers
  1. dlcto: Right([YourCombinedDatesField],InstrRev([YourCombinedDatesField], " ")-3)
(5) Now on your form or in reports you can simple refer to these two fields as if they actually existed in your table.

For you appearance on you form you could use something like:

Expand|Select|Wrap|Line Numbers
  1. Me.DisplayDates = "From: " & Me.dlcfrom & : To: " & dlcto
Note that in this method the only requirements is that the original field has at least one space after the first "date" and at least one space before the second "date."

Linq ;0)>
Thank you Linq....That will be a new experiance for me. I am just trying it and will tell you the result.
Dec 11 '07 #7
hjozinovic
167 100+
This was my first succesfully answered thread. I received here a lot and I want to give something back. I'm glad I could help...
Wish you luck with your project!
h.
Dec 11 '07 #8
missinglinq
3,532 Expert 2GB
Even if you don't use it for this project, knowing how to use calculated fields in queries is a handy tool to have in your skill set!

Having your "dates" as text is fine as long as you're sure you'll never have to do any kind of date manipulation with them, and to be honest, Access is really fairly forgiving even then. Many functions such as DateDiff() and DateAdd() work fine with text "dates" as long as the text looks like a legimate date.

Linq ;0)>
Dec 11 '07 #9
Even if you don't use it for this project, knowing how to use calculated fields in queries is a handy tool to have in your skill set!

Having your "dates" as text is fine as long as you're sure you'll never have to do any kind of date manipulation with them, and to be honest, Access is really fairly forgiving even then. Many functions such as DateDiff() and DateAdd() work fine with text "dates" as long as the text looks like a legimate date.

Linq ;0)>
o.O May your sayings come true Mr. Linq that date manipulation will not make any problem because i am going to make an increment system according to the dlcfrom field that is the hiring date of an employee. I have put a thread regarding to this issue. Please if you can have a look at this.

http://www.thescripts.com/forum/thread747333.html
Dec 11 '07 #10

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

Similar topics

2
by: Ciar?n | last post by:
I have a field that contains codes like fhj#asds kjjljlj#12 And so on. What I want to do is create two new fields (field1 and filed2) that split the original filed at '#' If a field does...
1
by: Richard | last post by:
http://dynamicdrive.com/dynamicindex5/linkinfo.htm Using the above script, I have a plan whereby when the main link is active, two different content swaps take place. Column A shows the main...
1
by: Kay | last post by:
Hi I am using a listbox to view all my records in one of my tables. The problem I have is with the field "Streen Name". This is a lookup field from the table "streets" which contains all the...
2
by: Matt | last post by:
Hi, I'm ridiculously new to Access (about a week!) so please be patient! My database is a record of British Standards. Each has a unique identifier. Some are split into parts. I would like...
2
by: pawanez4u | last post by:
Hi All, This is Pavankumar, I am doing Attendance Management project in PHP. What i want is as a day increases i want to alter the table with new filed with name current date(i,e) 01 Nov 07 for...
3
by: Yas | last post by:
Hi everyone I am trying to create a DELETE Trigger. I have 2 tables. Table1 and Table2. Table 2 has all the same fields and records as Table1 + 1 extra column "date_removed" I would like that...
1
by: chris f | last post by:
I'm dynamically populating a Table control in ASP.NET 2. Each row has 4 columns but column #3 needs to be split into 3 rows and column #4 needs to be split into 4 rows. Each of these cells contains...
0
by: raj | last post by:
My Zope based application for a client has to generate annual audit reports with too wide tables of account-wise payment details. I turned to reportlab when HTML formatting became a headache for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.