473,378 Members | 1,084 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,378 software developers and data experts.

Extracting dates from a memo field

Hello.

I need to extract date information from a memo field entered in the
following way: 01/01/2005 - 31/12/2005 01/01/2004 - 31/12/2004
01/01/2003 - 31/12/2003 01/01/1996 - 31/12/1996. The number of entries
varies.

I would welcome advice on a more elegant way of extracting all the date
information (first date, second date, third date, etc and appending to
another table, say tblDates) rather than the crude way I have used left
and mid.

Thanks in advance.

Kulwant Lall

Apr 27 '06 #1
5 1966
Baz

<kl***@yahoo.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
Hello.

I need to extract date information from a memo field entered in the
following way: 01/01/2005 - 31/12/2005 01/01/2004 - 31/12/2004
01/01/2003 - 31/12/2003 01/01/1996 - 31/12/1996. The number of entries
varies.

I would welcome advice on a more elegant way of extracting all the date
information (first date, second date, third date, etc and appending to
another table, say tblDates) rather than the crude way I have used left
and mid.

Thanks in advance.

Kulwant Lall


The "Split" function may be of assistance. You can find it in "Help"
Apr 27 '06 #2
ADezii
8,834 Expert 8TB
Hello.

I need to extract date information from a memo field entered in the
following way: 01/01/2005 - 31/12/2005 01/01/2004 - 31/12/2004
01/01/2003 - 31/12/2003 01/01/1996 - 31/12/1996. The number of entries
varies.

I would welcome advice on a more elegant way of extracting all the date
information (first date, second date, third date, etc and appending to
another table, say tblDates) rather than the crude way I have used left
and mid.

Thanks in advance.

Kulwant Lall
'Here is a routine that I wrote for you which will extract all 10 character
'date values from a Memo field called [MyMemo] and print them to the Debug
'Window. Should you need the additional code to write them to a Table,
'please let me know. Don't forget, the code is based on the assumption that
'all Date fields are of the format MM/DD/YYYY or DD/MM/YYYY. Hope this helps:


================================================== ========

Dim MyDB As Database, MyRS As Recordset, T As Integer

Set MyDB = CurrentDb()
Set MyRS = MyDB.OpenRecordset("tblEmployees", dbOpenSnapshot)

Do While Not MyRS.EOF
If Not IsNull(MyRS![MyMemo]) Then
For T = 1 To Len(MyRS![MyMemo])
If Mid(MyRS![MyMemo], T, 1) = "/" Then
If IsDate(Mid(MyRS![MyMemo], T - 2, 10)) And Len(Mid(MyRS![MyMemo], T - 2, 10)) = 10 Then
Debug.Print Mid(MyRS![MyMemo], T - 2, 10)
End If
End If
Next T
End If
MyRS.MoveNext
Loop

MyRS.Close
================================================== ========
Apr 28 '06 #3
use Split to get the dates into an array, then step through the array
to write them to a table.

You failed to mention something, though. Are the date pairs the _only_
thing in the memo field? That's key, because otherwise, you may be
trying to parse text and treat it as if it were a date, which won't
work so well.

This should at least get you started...

'01/01/2005 - 12/31/2005 01/01/2004 - 12/31/2004
'01/01/2003 - 12/31/2003 01/01/1996 - 12/31/1996 4/1/2006 - 5/3/2006

Public Function SplitDateRanges(ByVal strDateList As String)
Dim strTemp As String
Dim varDateList As Variant
Dim varStartEndDates As Variant
Dim intCounter As Integer

strTemp = Replace(strDateList, " - ", "-", 1)
SplitDateRanges = strTemp
varDateList = Split(strTemp, " ")

For intCounter = 0 To UBound(varDateList)
If intCounter Mod 2 = 0 Then 'second of the pair..

'Debug.Print "varDateList(" & intCounter & "): " &
varDateList(intCounter)
varStartEndDates = Split(varDateList(intCounter), "-")
For intcounter2 = 0 To UBound(varStartEndDates)
Debug.Print varStartEndDates(intcounter2)
Next intcounter2
End If
Next intCounter
End Function

Apr 30 '06 #4
Thank you very much for your help. The code works well. The date pairs
are the only thing in the memo field. The final step will be to write
to a table.

Best wishes

Kulwant

May 2 '06 #5
Thanks for your input. It was very useful.

Best wishes

Kulwant

May 2 '06 #6

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

Similar topics

6
by: Shyguy | last post by:
I want to create two buttons on a form. One would allow the user to Copy the contents of the current records memo field, the other would allow them to print. I set up a report based on the memo...
3
by: GorDon | last post by:
Hi, I have a report based on a query. The query grabs a memo field from my main table, yet when I display the memo field in the report it truncates the memo field (the field needs to hold more...
4
by: intl04 | last post by:
I have a memo field that is included in some Access reports I created. Is there some way for the memo field to display nicely formatted text, with line breaks between paragraphs? Or is it necessary...
2
by: Bob Dydd | last post by:
Hi Everybody I have a Listbox that has a Memo field attached to it's 2nd column which on double click copies the memo field to another Memo Field. Forms!! = ListClassification.Column(1) My...
3
by: John | last post by:
I have a field, data type Memo, in a job details table. I have a text box on a report which I need to print the contents of this field. My problem is that the text box will only display 255...
5
by: Bluecove | last post by:
After many unsuccessful attempts at this, including the use of software from Sobolsoft, I need help! I have a table comprised of thousands of long records (all in one column which is Memo type)....
2
by: Roger | last post by:
I've got two tables in sql2005 which have an 'ntext' field when I linked the first table in access97 last week using an odbc data source the access-field type was 'memo' when I link the 2nd...
10
by: ARC | last post by:
This is mainly a speed question. In this example: I have a QuotesHdr table that has a few memo fields. If these memo fields are used extensively by some users, and if their are a large number of...
11
tdw
by: tdw | last post by:
Hi all, I have tried a few different methods to accomplish this, but with no luck. I will post the code for the latest attempt at the end of this post. I work at a land surveying company. This...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.