text field to date field field

I have a database that has a text field called "visit"  it has been
filled with data ie.,    " 6/22/07 - not good, "   the field may also
be blank or it may contain random text after the date. In some cases
no date at all just text. I would like to create a new field called
DateVisit that contains just the dates that were entered in the field
"visit"

      it has been a struggle and I have made no progress

please help

abbenj@verizon.net/nospam
0
andyb
1/29/2008 12:30:53 AM
access.queries 6343 articles. 1 followers. Follow

11 Replies
1414 Views

Similar Articles

[PageSpeed] 35

From your description, the field might contain a date, or a date and text, 
or text, or nothing.

How would you explain to a live person how to tell the difference?  How do 
you propose to tell Access how to tell the difference?

How many of these do you have?

I suppose one alternative would be (depending on which version of Access you 
are using) to use the Split() function to see if any of the pieces can be 
converted to an Access Date/Time value.  You'll probably need to create your 
own function to "split" each record's value in that field, determine if any 
of the split pieces are date/times, then save those found to a new field.

Got VB?

Regards

Jeff Boyce
Microsoft Office/Access MVP


"andyb" <abbenj@verizon.net> wrote in message 
news:f4136430-08aa-4778-b247-5b429e802e55@v67g2000hse.googlegroups.com...
>I have a database that has a text field called "visit"  it has been
> filled with data ie.,    " 6/22/07 - not good, "   the field may also
> be blank or it may contain random text after the date. In some cases
> no date at all just text. I would like to create a new field called
> DateVisit that contains just the dates that were entered in the field
> "visit"
>
>      it has been a struggle and I have made no progress
>
> please help
>
> abbenj@verizon.net/nospam 


0
Jeff
1/29/2008 12:55:51 AM
On Jan 28, 7:55=A0pm, "Jeff Boyce" <nonse...@nonsense.com> wrote:
> From your description, the field might contain a date, or a date and text,=

> or text, or nothing.
>
> How would you explain to a live person how to tell the difference? =A0How =
do
> you propose to tell Access how to tell the difference?
>
> How many of these do you have?
>
> I suppose one alternative would be (depending on which version of Access y=
ou
> are using) to use the Split() function to see if any of the pieces can be
> converted to an Access Date/Time value. =A0You'll probably need to create =
your
> own function to "split" each record's value in that field, determine if an=
y
> of the split pieces are date/times, then save those found to a new field.
>
> Got VB?
>
> Regards
>
> Jeff Boyce
> Microsoft Office/Access MVP
>
> "andyb" <abb...@verizon.net> wrote in message
>
> news:f4136430-08aa-4778-b247-5b429e802e55@v67g2000hse.googlegroups.com...
>
>
>
> >I have a database that has a text field called "visit" =A0it has been
> > filled with data ie., =A0 =A0" 6/22/07 - not good, " =A0 the field may a=
lso
> > be blank or it may contain random text after the date. In some cases
> > no date at all just text. I would like to create a new field called
> > DateVisit that contains just the dates that were entered in the field
> > "visit"
>
> > =A0 =A0 =A0it has been a struggle and I have made no progress
>
> > please help
>
> > abb...@verizon.net/nospam- Hide quoted text -
>
> - Show quoted text -

Use the split function in a query?

I have 747 records like these.

I would tell a person to ignore any alpha characters, and emty fields

Andy
0
andyb
1/29/2008 1:26:23 AM
On Mon, 28 Jan 2008 16:30:53 -0800 (PST), andyb <abbenj@verizon.net> wrote:

>I have a database that has a text field called "visit"  it has been
>filled with data ie.,    " 6/22/07 - not good, "   the field may also
>be blank or it may contain random text after the date. In some cases
>no date at all just text. I would like to create a new field called
>DateVisit that contains just the dates that were entered in the field
>"visit"
>
>      it has been a struggle and I have made no progress
>
>please help
>
>abbenj@verizon.net/nospam

If you can assume that the leftmost portion of the string (with any blanks
trimmed off) is a date, or else that there is no date, then try:

IIf(IsDate(Left(Trim([visit], InStr([visit], " ") - 1)),
CDate((Left(Trim([visit], InStr([visit], " ") - 1)), Null)


             John W. Vinson [MVP]

 
0
John
1/29/2008 3:45:57 AM
First question is there MORE than one date in the field?  Assuming only one 
date the function below should work to give you the date as a string.

Function fExtractDate(strIn)
Dim s As Variant
Dim i As Long

   If Len(strIn & "") = 0 Then Exit Function

   s = Split(strIn, " ")
   For i = LBound(s) To UBound(s)
       If IsDate(s(i)) Then
         fExtractDate = s(i)
         ' Or if you wanted the date back as a datetime field
         ' fExtractDate = CDate(s(i) )
          Exit Function
      End If
   Next i

End Function

In your query you would call it as
Field: TheDate: fExtractDate([Name of the field])
-- 
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"andyb" <abbenj@verizon.net> wrote in message 
news:f5c4507f-9eda-478d-9783-c1776cb3ff53@s12g2000prg.googlegroups.com...
On Jan 28, 7:55 pm, "Jeff Boyce" <nonse...@nonsense.com> wrote:
> From your description, the field might contain a date, or a date and text,
> or text, or nothing.
>
> How would you explain to a live person how to tell the difference? How do
> you propose to tell Access how to tell the difference?
>
> How many of these do you have?
>
> I suppose one alternative would be (depending on which version of Access 
> you
> are using) to use the Split() function to see if any of the pieces can be
> converted to an Access Date/Time value. You'll probably need to create 
> your
> own function to "split" each record's value in that field, determine if 
> any
> of the split pieces are date/times, then save those found to a new field.
>
> Got VB?
>
> Regards
>
> Jeff Boyce
> Microsoft Office/Access MVP
>
> "andyb" <abb...@verizon.net> wrote in message
>
> news:f4136430-08aa-4778-b247-5b429e802e55@v67g2000hse.googlegroups.com...
>
>
>
> >I have a database that has a text field called "visit" it has been
> > filled with data ie., " 6/22/07 - not good, " the field may also
> > be blank or it may contain random text after the date. In some cases
> > no date at all just text. I would like to create a new field called
> > DateVisit that contains just the dates that were entered in the field
> > "visit"
>
> > it has been a struggle and I have made no progress
>
> > please help
>
> > abb...@verizon.net/nospam- Hide quoted text -
>
> - Show quoted text -

Use the split function in a query?

I have 747 records like these.

I would tell a person to ignore any alpha characters, and emty fields

Andy 


0
John
1/29/2008 12:59:05 PM
On Jan 28, 10:45=A0pm, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Mon, 28 Jan 2008 16:30:53 -0800 (PST), andyb <abb...@verizon.net> wrote=
:
> >I have a database that has a text field called "visit" =A0it has been
> >filled with data ie., =A0 =A0" 6/22/07 - not good, " =A0 the field may al=
so
> >be blank or it may contain random text after the date. In some cases
> >no date at all just text. I would like to create a new field called
> >DateVisit that contains just the dates that were entered in the field
> >"visit"
>
> > =A0 =A0 =A0it has been a struggle and I have made no progress
>
> >please help
>
> >abb...@verizon.net/nospam
>
> If you can assume that the leftmost portion of the string (with any blanks=

> trimmed off) is a date, or else that there is no date, then try:
>
> IIf(IsDate(Left(Trim([visit], InStr([visit], " ") - 1)),
> CDate((Left(Trim([visit], InStr([visit], " ") - 1)), Null)
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0John W. Vinson [MVP]


Hi John

      It did not work. I kept getting wrong number of arguments error.

0
andyb
1/29/2008 10:29:52 PM
This might work if the Date is always right at the beginning of the field.


IIF(IsDate(Left(Trim(Visit & ""),Instr(1,Trim(Visit & ""),
" ")),Left(Trim(Visit),Instr(1,Trim(Visit)," "),Null)

'====================================================
  John Spencer
  Access MVP 2002-2005, 2007-2008
  Center for Health Program Development and Management
  University of Maryland Baltimore County
'====================================================


andyb wrote:
> On Jan 28, 10:45 pm, John W. Vinson
> <jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
>> On Mon, 28 Jan 2008 16:30:53 -0800 (PST), andyb <abb...@verizon.net> wrote:
>>> I have a database that has a text field called "visit"  it has been
>>> filled with data ie.,    " 6/22/07 - not good, "   the field may also
>>> be blank or it may contain random text after the date. In some cases
>>> no date at all just text. I would like to create a new field called
>>> DateVisit that contains just the dates that were entered in the field
>>> "visit"
>>>      it has been a struggle and I have made no progress
>>> please help
>>> abb...@verizon.net/nospam
>> If you can assume that the leftmost portion of the string (with any blanks
>> trimmed off) is a date, or else that there is no date, then try:
>>
>> IIf(IsDate(Left(Trim([visit], InStr([visit], " ") - 1)),
>> CDate((Left(Trim([visit], InStr([visit], " ") - 1)), Null)
>>
>>              John W. Vinson [MVP]
> 
> 
> Hi John
> 
>       It did not work. I kept getting wrong number of arguments error.
> 
0
John
1/30/2008 12:14:15 AM
On Jan 29, 7:14=A0pm, John Spencer <spen...@chpdm.umbc> wrote:
> This might work if the Date is always right at the beginning of the field.=

>
> IIF(IsDate(Left(Trim(Visit & ""),Instr(1,Trim(Visit & ""),
> " ")),Left(Trim(Visit),Instr(1,Trim(Visit)," "),Null)
>
> '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> =A0 John Spencer
> =A0 Access MVP 2002-2005, 2007-2008
> =A0 Center for Health Program Development and Management
> =A0 University of Maryland Baltimore County
> '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
>
>
>
> andyb wrote:
> > On Jan 28, 10:45 pm, John W. Vinson
> > <jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> >> On Mon, 28 Jan 2008 16:30:53 -0800 (PST), andyb <abb...@verizon.net> wr=
ote:
> >>> I have a database that has a text field called "visit" =A0it has been
> >>> filled with data ie., =A0 =A0" 6/22/07 - not good, " =A0 the field may=
 also
> >>> be blank or it may contain random text after the date. In some cases
> >>> no date at all just text. I would like to create a new field called
> >>> DateVisit that contains just the dates that were entered in the field
> >>> "visit"
> >>> =A0 =A0 =A0it has been a struggle and I have made no progress
> >>> please help
> >>> abb...@verizon.net/nospam
> >> If you can assume that the leftmost portion of the string (with any bla=
nks
> >> trimmed off) is a date, or else that there is no date, then try:
>
> >> IIf(IsDate(Left(Trim([visit], InStr([visit], " ") - 1)),
> >> CDate((Left(Trim([visit], InStr([visit], " ") - 1)), Null)
>
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0John W. Vinson [MVP]
>
> > Hi John
>
> > =A0 =A0 =A0 It did not work. I kept getting wrong number of arguments er=
ror.- Hide quoted text -
>
> - Show quoted text -

I have been putting the statement in the criteria in design mode and
it is just not working
0
andyb
1/30/2008 12:47:45 AM
On Jan 29, 7:59=A0am, "John Spencer" <spen...@chpdm.edu> wrote:
> First question is there MORE than one date in the field? =A0Assuming only =
one
> date the function below should work to give you the date as a string.
>
> Function fExtractDate(strIn)
> Dim s As Variant
> Dim i As Long
>
> =A0 =A0If Len(strIn & "") =3D 0 Then Exit Function
>
> =A0 =A0s =3D Split(strIn, " ")
> =A0 =A0For i =3D LBound(s) To UBound(s)
> =A0 =A0 =A0 =A0If IsDate(s(i)) Then
> =A0 =A0 =A0 =A0 =A0fExtractDate =3D s(i)
> =A0 =A0 =A0 =A0 =A0' Or if you wanted the date back as a datetime field
> =A0 =A0 =A0 =A0 =A0' fExtractDate =3D CDate(s(i) )
> =A0 =A0 =A0 =A0 =A0 Exit Function
> =A0 =A0 =A0 End If
> =A0 =A0Next i
>
> End Function
>
> In your query you would call it as
> Field: TheDate: fExtractDate([Name of the field])
> --
> John Spencer
> Access MVP 2002-2005, 2007-2008
> Center for Health Program Development and Management
> University of Maryland Baltimore County
> .
>
> "andyb" <abb...@verizon.net> wrote in message
>
> news:f5c4507f-9eda-478d-9783-c1776cb3ff53@s12g2000prg.googlegroups.com...
> On Jan 28, 7:55 pm, "Jeff Boyce" <nonse...@nonsense.com> wrote:
>
>
>
>
>
> > From your description, the field might contain a date, or a date and tex=
t,
> > or text, or nothing.
>
> > How would you explain to a live person how to tell the difference? How d=
o
> > you propose to tell Access how to tell the difference?
>
> > How many of these do you have?
>
> > I suppose one alternative would be (depending on which version of Access=

> > you
> > are using) to use the Split() function to see if any of the pieces can b=
e
> > converted to an Access Date/Time value. You'll probably need to create
> > your
> > own function to "split" each record's value in that field, determine if
> > any
> > of the split pieces are date/times, then save those found to a new field=
..
>
> > Got VB?
>
> > Regards
>
> > Jeff Boyce
> > Microsoft Office/Access MVP
>
> > "andyb" <abb...@verizon.net> wrote in message
>
> >news:f4136430-08aa-4778-b247-5b429e802e55@v67g2000hse.googlegroups.com...=

>
> > >I have a database that has a text field called "visit" it has been
> > > filled with data ie., " 6/22/07 - not good, " the field may also
> > > be blank or it may contain random text after the date. In some cases
> > > no date at all just text. I would like to create a new field called
> > > DateVisit that contains just the dates that were entered in the field
> > > "visit"
>
> > > it has been a struggle and I have made no progress
>
> > > please help
>
> > > abb...@verizon.net/nospam- Hide quoted text -
>
> > - Show quoted text -
>
> Use the split function in a query?
>
> I have 747 records like these.
>
> I would tell a person to ignore any alpha characters, and emty fields
>
> Andy- Hide quoted text -
>
> - Show quoted text -

It works nice until it encounters a character right next to the date.
ie., 09/22/06-good
the - or letter next to the last number messes it up
0
andyb
1/30/2008 12:49:25 AM
On Tue, 29 Jan 2008 16:47:45 -0800 (PST), andyb <abbenj@verizon.net> wrote:

>I have been putting the statement in the criteria in design mode and
>it is just not working

Sorry... should have explained better. This is not a CRITERION on a field;
this is instead a calculated date/time field extracted from the text field.
Put the expression in a vacant Field cell in the query grid.

             John W. Vinson [MVP]
0
John
1/30/2008 1:20:39 AM
Now you know the reason that having this data stored with other data items 
is a bad idea.

Using Regular expression to snag the date looks like your best choice.  I'm 
not up to that challenge.

You would need to find and extract data that matched the pattern
1 or 2 numbers, a separator character, 1 or 2 numbers, a separator 
character, and 2 or 4 numbers.

You can try the following function (not fully tested).  It looks for date 
strings in several configurations in order of length.
-- It first looks for a 10 character date mm/dd/yyyy and returns the first 
instance of that
-- If no 10 character date is found it looks for a 9 character date 
m/dd/yyyy or mm/d/yyyy and returns the first instance of that
-- (8) Then m/d/yyyy or mm/dd/yy
-- (7) Then m/d/yy or mm/d/yy or m/dd/yy
-- (6) Then m/d/yy

Function fExtractDatePattern(strIn)
Dim i As Long
Dim strDate As String
Const Cs1 As String = "#[-/.]"
Const Cs2 As String = "##[-/.]"
Const Cs2y As String = "##"
Const Cs4y As String = "####"
'Warning this works for US date patterns
'It may or may not work for other patterns

   If Len(strIn & "") > 5 Then

      For i = 1 To Len(strIn) - 9
         If Mid(strIn, i, 10) Like Cs2 & Cs2 & Cs4y And _
            IsDate(Mid(strIn, i, 10)) Then 'mm/dd/yyyy
            strDate = Mid(strIn, i, 10)
            Exit For
         End If
      Next i

      If Len(strDate) = 0 Then
         For i = 1 To Len(strIn) - 8
         If (Mid(strIn, i, 9) Like Cs1 & Cs2 & Cs4y Or _
            Mid(strIn, i, 9) Like Cs2 & Cs1 & Cs4y) And _
            IsDate(Mid(strIn, i, 9)) Then 'm/dd/yy or mm/d/yyyy
               strDate = Mid(strIn, i, 9)
               Exit For
            End If
         Next i
      End If

       If Len(strDate) = 0 Then
         For i = 1 To Len(strIn) - 7
            If (Mid(strIn, i, 8) Like Cs2 & Cs2 & Cs2y Or _
               Mid(strIn, i, 8) Like Cs1 & Cs1 & Cs4y) And _
               IsDate(Mid(strIn, i, 8)) Then 'mm/dd/yy or m/d/yyyy
               strDate = Mid(strIn, i, 8)
               Exit For
            End If
         Next i
      End If

       If Len(strDate) = 0 Then
         For i = 1 To Len(strIn) - 6
            If (Mid(strIn, i, 7) Like Cs1 & Cs2 & Cs4y Or _
               Mid(strIn, i, 7) Like Cs2 & Cs1 & Cs4y) And _
               IsDate(Mid(strIn, i, 7)) Then 'm/dd/yyyy or mm/d/yyyy
               strDate = Mid(strIn, i, 7)
               Exit For
            End If
         Next i
      End If

      If Len(strDate) = 0 Then
         For i = 1 To Len(strIn) - 5
            If Mid(strIn, i, 7) Like Cs1 & Cs1 & Cs2y And _
               IsDate(Mid(strIn, i, 6)) Then 'm/d/yy
               strDate = Mid(strIn, i, 6)
               Exit For
            End If
         Next i
      End If

      If Len(strDate) > 0 Then 'found a date
         fExtractDatePattern = strDate
      End If

   End If


End Function




-- 
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

It works nice until it encounters a character right next to the date.
ie., 09/22/06-good
the - or letter next to the last number messes it up

"andyb" <abbenj@verizon.net> wrote in message 
news:bc48883d-9a98-4f14-b6a9-21da7fbaceca@1g2000hsl.googlegroups.com...
On Jan 29, 7:59 am, "John Spencer" <spen...@chpdm.edu> wrote:
> First question is there MORE than one date in the field? Assuming only one
> date the function below should work to give you the date as a string.
>
> Function fExtractDate(strIn)
> Dim s As Variant
> Dim i As Long
>
> If Len(strIn & "") = 0 Then Exit Function
>
> s = Split(strIn, " ")
> For i = LBound(s) To UBound(s)
> If IsDate(s(i)) Then
> fExtractDate = s(i)
> ' Or if you wanted the date back as a datetime field
> ' fExtractDate = CDate(s(i) )
> Exit Function
> End If
> Next i
>
> End Function
>
> In your query you would call it as
> Field: TheDate: fExtractDate([Name of the field])
> --
> John Spencer
> Access MVP 2002-2005, 2007-2008
> Center for Health Program Development and Management
> University of Maryland Baltimore County
> .
>



0
John
1/30/2008 2:09:09 PM
On Jan 30, 9:09=A0am, "John Spencer" <spen...@chpdm.edu> wrote:
> Now you know the reason that having this data stored with other data items=

> is a bad idea.
>
> Using Regular expression to snag the date looks like your best choice. =A0=
I'm
> not up to that challenge.
>
> You would need to find and extract data that matched the pattern
> 1 or 2 numbers, a separator character, 1 or 2 numbers, a separator
> character, and 2 or 4 numbers.
>
> You can try the following function (not fully tested). =A0It looks for dat=
e
> strings in several configurations in order of length.
> -- It first looks for a 10 character date mm/dd/yyyy and returns the first=

> instance of that
> -- If no 10 character date is found it looks for a 9 character date
> m/dd/yyyy or mm/d/yyyy and returns the first instance of that
> -- (8) Then m/d/yyyy or mm/dd/yy
> -- (7) Then m/d/yy or mm/d/yy or m/dd/yy
> -- (6) Then m/d/yy
>
> Function fExtractDatePattern(strIn)
> Dim i As Long
> Dim strDate As String
> Const Cs1 As String =3D "#[-/.]"
> Const Cs2 As String =3D "##[-/.]"
> Const Cs2y As String =3D "##"
> Const Cs4y As String =3D "####"
> 'Warning this works for US date patterns
> 'It may or may not work for other patterns
>
> =A0 =A0If Len(strIn & "") > 5 Then
>
> =A0 =A0 =A0 For i =3D 1 To Len(strIn) - 9
> =A0 =A0 =A0 =A0 =A0If Mid(strIn, i, 10) Like Cs2 & Cs2 & Cs4y And _
> =A0 =A0 =A0 =A0 =A0 =A0 IsDate(Mid(strIn, i, 10)) Then 'mm/dd/yyyy
> =A0 =A0 =A0 =A0 =A0 =A0 strDate =3D Mid(strIn, i, 10)
> =A0 =A0 =A0 =A0 =A0 =A0 Exit For
> =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0 Next i
>
> =A0 =A0 =A0 If Len(strDate) =3D 0 Then
> =A0 =A0 =A0 =A0 =A0For i =3D 1 To Len(strIn) - 8
> =A0 =A0 =A0 =A0 =A0If (Mid(strIn, i, 9) Like Cs1 & Cs2 & Cs4y Or _
> =A0 =A0 =A0 =A0 =A0 =A0 Mid(strIn, i, 9) Like Cs2 & Cs1 & Cs4y) And _
> =A0 =A0 =A0 =A0 =A0 =A0 IsDate(Mid(strIn, i, 9)) Then 'm/dd/yy or mm/d/yyy=
y
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strDate =3D Mid(strIn, i, 9)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Exit For
> =A0 =A0 =A0 =A0 =A0 =A0 End If
> =A0 =A0 =A0 =A0 =A0Next i
> =A0 =A0 =A0 End If
>
> =A0 =A0 =A0 =A0If Len(strDate) =3D 0 Then
> =A0 =A0 =A0 =A0 =A0For i =3D 1 To Len(strIn) - 7
> =A0 =A0 =A0 =A0 =A0 =A0 If (Mid(strIn, i, 8) Like Cs2 & Cs2 & Cs2y Or _
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Mid(strIn, i, 8) Like Cs1 & Cs1 & Cs4y) And=
 _
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IsDate(Mid(strIn, i, 8)) Then 'mm/dd/yy or =
m/d/yyyy
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strDate =3D Mid(strIn, i, 8)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Exit For
> =A0 =A0 =A0 =A0 =A0 =A0 End If
> =A0 =A0 =A0 =A0 =A0Next i
> =A0 =A0 =A0 End If
>
> =A0 =A0 =A0 =A0If Len(strDate) =3D 0 Then
> =A0 =A0 =A0 =A0 =A0For i =3D 1 To Len(strIn) - 6
> =A0 =A0 =A0 =A0 =A0 =A0 If (Mid(strIn, i, 7) Like Cs1 & Cs2 & Cs4y Or _
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Mid(strIn, i, 7) Like Cs2 & Cs1 & Cs4y) And=
 _
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IsDate(Mid(strIn, i, 7)) Then 'm/dd/yyyy or=
 mm/d/yyyy
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strDate =3D Mid(strIn, i, 7)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Exit For
> =A0 =A0 =A0 =A0 =A0 =A0 End If
> =A0 =A0 =A0 =A0 =A0Next i
> =A0 =A0 =A0 End If
>
> =A0 =A0 =A0 If Len(strDate) =3D 0 Then
> =A0 =A0 =A0 =A0 =A0For i =3D 1 To Len(strIn) - 5
> =A0 =A0 =A0 =A0 =A0 =A0 If Mid(strIn, i, 7) Like Cs1 & Cs1 & Cs2y And _
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IsDate(Mid(strIn, i, 6)) Then 'm/d/yy
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strDate =3D Mid(strIn, i, 6)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Exit For
> =A0 =A0 =A0 =A0 =A0 =A0 End If
> =A0 =A0 =A0 =A0 =A0Next i
> =A0 =A0 =A0 End If
>
> =A0 =A0 =A0 If Len(strDate) > 0 Then 'found a date
> =A0 =A0 =A0 =A0 =A0fExtractDatePattern =3D strDate
> =A0 =A0 =A0 End If
>
> =A0 =A0End If
>
> End Function
>
> --
> John Spencer
> Access MVP 2002-2005, 2007-2008
> Center for Health Program Development and Management
> University of Maryland Baltimore County
> .
>
> It works nice until it encounters a character right next to the date.
> ie., 09/22/06-good
> the - or letter next to the last number messes it up
>
> "andyb" <abb...@verizon.net> wrote in message
>
> news:bc48883d-9a98-4f14-b6a9-21da7fbaceca@1g2000hsl.googlegroups.com...
> On Jan 29, 7:59 am, "John Spencer" <spen...@chpdm.edu> wrote:
>
>
>
> > First question is there MORE than one date in the field? Assuming only o=
ne
> > date the function below should work to give you the date as a string.
>
> > Function fExtractDate(strIn)
> > Dim s As Variant
> > Dim i As Long
>
> > If Len(strIn & "") =3D 0 Then Exit Function
>
> > s =3D Split(strIn, " ")
> > For i =3D LBound(s) To UBound(s)
> > If IsDate(s(i)) Then
> > fExtractDate =3D s(i)
> > ' Or if you wanted the date back as a datetime field
> > ' fExtractDate =3D CDate(s(i) )
> > Exit Function
> > End If
> > Next i
>
> > End Function
>
> > In your query you would call it as
> > Field: TheDate: fExtractDate([Name of the field])
> > --
> > John Spencer
> > Access MVP 2002-2005, 2007-2008
> > Center for Health Program Development and Management
> > University of Maryland Baltimore County
> > .- Hide quoted text -
>
> - Show quoted text -

I am sorry I have not got back to anyone as of yet. What I ended up
doing was running the function extract by John Spencer.  What it
missed as a result of random characters being to the right I
eliminated with a simple search and replace. I then ran the function
again and it was all fixed.

   Thanks to all for the great stuff suggested. Sorry again for the
late reply

Andy Benjamin
0
andyb
2/10/2008 10:56:58 PM
Reply:

Similar Artilces:

Date & Time Stamp does not update
I have created a form in a Public Journal Folder. When I add a new Journal Entry the date and time is the same as the date and time that I created the form. I do I get the form to update? ...

Business Alerts-Basaed on Date
Hi, I have a requirement to create a business alert when a PO is raised for a specific supplier. My problem is to get the alert to work on a date based logic. Does any one know of a function or a work around to get the alert to work on say within the x days from today. Appreciate your comments. Hi, Please ldrop a email if you are interested in learning about our custom Business alert solution for GP. Regards, NJ nj.tech@hotmail.com "PR" wrote: > Hi, > I have a requirement to create a business alert when a PO is raised for a > specific supplier. My problem is to ge...

TEXT = text
I have some data in an Excel table which uses case sensitive codes. Does anyone know of a way to perform case sensitive VLookups. Example. A1 contains "TEXT", A2 contains "One". B1 contains "text", B2 contains "Two" If I enter "text" in cell A4 and the following VLookup in B4: =VLOOKUP(A4;A1:B2;2;FALSE) I get the answer "One", but I would like to see "Two". I have found a work around by converting a number of characters to their ASCII codes, but this is very messy. I know that the FIND function is case sensitive whe...

How can I create an ASCII file with double quotes around each field?
I need to convert Excel files to ASCII files with commas as delimiters. That part is easy. The problem is that I need each field to be surounded by double quotes. Here is an example of what my ASCII output needs to look like: "smith","robert","15","elm","street" "jones","robert","111","main","avenue" Can anyone suggest a solution on how I can convert my excel file to ASCII output as shown in my example? thanks very much! I can get the data into the correct format but then you will need to ...

Selecting text in a document
Hi, I have a macro which finds a certain piece of text in the document and then moves down a line and then selects all the text between that and the end of the document and the selected text is later sent out in an email. This has been working for some time but I have recently had some problems because the text is not being selected as before (extendmode on?) and I am sending out blank emails. The code fragment that I use to select the text is as follows Selection.HomeKey wdStory Selection.Find.Execute "Issued at" Selection.MoveDo...

What is the Limit of Text Boxes & Labels a User Form can have?
What is the Max File Size a User Form can be? I have Windows 7 with Office 2007. Does it have like a 64K limit? The file size as far as kb. My entire Program is 1,203 Kb. When I ran it I got a "compile Error out of memory", so I exported my User Form. Then I looked at the file size of just the User Form in a blank Workbook 34 KB = .frm 219 KB = frx My user Form is a Multi Page with 4 Pages on it. There are alot of text boxes and labels on the 4 sheets. Is there a limit to the number of text boxes & labels you can have in a user Form? I have 12 GB of ...

Resizing cells to fit text returned by VLOOKUP
I have some VLOOKUPs which sometimes return 50 or 60 characters (they're in merged cells). I want the text to wrap, and the cell to enlarge to fit the text - Just like it does whan you type it in, but somehow, because it is being returned from a formula it just displays the bottom line of the wrapped text, and doesn't resize the row. Anyone know how I cam make it fit? I'm happy to use a VBA solution if there's no built in way to make it happen automatically. Thanks M Would you mind to limit your request to ONE newsgroup? Joerg "Michelle" <mh_londonNOJUN...

CScrollView and text height
I call DrawText to draw text on the CScrollView.When text has multi-line,how do I get the screen height to draw them? Thanks. ___________________________________ http://www.msale.net/bbs a Chinese-language message board for developers,including palm,ppc,symbian,and etc. http://www.zirong.net/blog/ Miken's private life If you are trying to calculate the height of a multiline string user DrawText with the DT_CALCRECT flag. It will use the width of the Rect that you pass it, and sets the bottom of the rect to what the bottom would be if you draw it. AliR. "Miken" <mikenwon...

Crm field help
Hi there, is there any easy way to introduce help info when passing with the mouse pointer above a field? Thanks in advance! ...

QUERY FIELD SUM
In have the following in my first field. K:IIF([PL4HX4.RK]=1,"2",IIF([PL4HX4.RK]=2,"1","")) I have the following in my second field. H:IIF([PL4HX4.RH]=1,"2",IIF([PL4HX4.RH]=2,"1","")) What would i write in my third field to get the sum of K + H ? Thanks ed should be as easy as: L: [K] + [H] However, you see that you are returning "1" which is a string, as opposed 1 the number. You might want to change the values to 2, 1, and 0 depending on what you are trying to accomplish. >> What would i writ...

Text Boxes on Charts not showing up
Has anyone experienced this? I've got a chart in a spreadsheet and I add text boxes to the graph section. They appear on the page yet when I click off the page, the text box disappears. If I go to print preview, the text boxes are there so why can't I see them on the screen? I've tried the bring forward command but that didn't work. This is also sporadic as some of my text boxes stay in place why others seem to disappear. Sue - If the chart is selected when you draw the text box, the text box becomes part of the chart. If not, the text box just floats along in the dr...

problem about working with dates.
Column 1 contains a list of dates in format DD/MM/YYYY I want to manipulate this data such that another column shows MM-YY based on data in column 1. The change from slashes to hyphen separation is required. How can I do this? [Does not need to be done in one step. I tried using the =right(_, _) command to seperate the '08' off with the intent of concatenating the seperated stuff back together- but this did not work.] ss Simon If the dates in column A are truly dates just format the new column as mm-yy should suffice -- HTH Nick Hodge Microsoft MVP - Excel Southa...

avoid losing text when text submission timed out?
Often I have to log in to some web site to enter a few paragraphs of text (e.g. web email submission, user forum, product reviews, etc). Sometimes it takes me a while to compose the text, and by the time I click submit, I get a response saying the session has timed out, and the text that took me a long time to compose is gone. Is there a way to retrieve this text? Clicking the back button doesn't work. Perhaps it is in a cache somewhere? The portion of the web page containing your text may or may not be in TIF, but here's what I do: Before I hit the 'Submit'...

Ranking Numbers with Text
I am trying to sort a list of serial numbers containing alpha an numeric text into ascending order so LOOKUP will work. ie: 5KJJAHAS63PL84681 input into col. E 5KJJAHAS43PL84685 5KJJAHASx3PL84683 5KJJAHAS83PL84686 5KJJAHAS63PL84689 5KJJAHAS43PL84684 5KJJAHAS23PL84682 5KJJAHAS03PL84688 5KJJAHASx3PL84610 5KJJAHAS83PL84690 5KJJAHAS83PL84691 Only the ninth and 13 thru 17 digits change. Worksheets are protected except for inputs. I need the sort to use the LOOKUP function. I tried =IF(E3>0,(RIGHT(E3,5)*1),999999) to RANK by the last 5 =RANK(D3,D$3:D$102,1)+COUNTIF(D$3:D3,D3)-1, but then LOOKUP ...

convert text case in same column or row?
How do I convert text case in the same colum or row. At the moment I use UPPER, but have to create a new column/row. You may find this to be handy Sub ChangeCase() 'Don Guillett Application.ScreenUpdating = False Dim r As Range nCase = UCase(InputBox("Enter U for UPPER" & Chr$(13) & " L for lower" & Chr$(13) & " Or " & Chr$(13) & " P for Proper", "Select Case Desired")) Select Case nCase Case "L" For Each r In Selection.Cells If r.HasFormula Then r.Formula = LCase(r.Formul...

I TYPE IN A TEXT BOX AND IT COPIES THE TEXT TO OTHER TEXT BOXES
Does anyone know how to fix this? Shari wrote: > Does anyone know how to fix this? ================================ Are you editing text on the Master page? -- John Inzer MS Picture It! - Digital Image MVP Digital Image Highlights and FAQs http://support.microsoft.com/ph/695 Notice This is not tech support I am a volunteer Solutions that work for me may not work for you Proceed at your own risk Yes, I thinnk so. :-) I'm not on the background. It's an 8 pg brochure I'm creating and it didn't do it before I added page 8. ...

want to save the record number in a field
This shold be simple, but I can't find and info on it. When starting a new record I would like to populate a field with the record number and save it in in the table. Record numbers you see at the bottom of the display are 'relative' only. Access stores records like a barrel of bricks, all in a jumble. You have to sort the records in a query, form, or report. But you can use a field with an Autonumber to number records. The numbers may not be continous without gaps but will be a unique value. -- Build a little, test a little. "fransquest" wrote...

Null in text box
Can anyone see what might be wrong withthis procedure? Private Sub Job_Number_BeforeUpdate(Cancel As Integer) If IsNull(Me.Job_Number) = True Then MsgBox "No Job Number Entered" Cancel = True End If End Sub -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200707/1 "Haggr1 via AccessMonster.com" <u35393@uwe> wrote in news:74fa8171f7137@uwe: > Can anyone see what might be wrong withthis procedure? > > Private Sub Job_Number_BeforeUpdate(Cancel As Integer) > > If IsNull(Me.Job_...

Joining fields
Can I join fields in a query? Example I have a Home Name, a Mothers name and a Fathers name. Can I join these in a query to show HOME, Father & Mother on 1 line? ...

ERROR check if a date set entered violates a perviously entered date set
I am devloping an excel program that has a list of date sets, not necessarily in sequencial order. What I want is an ERROR CHECK if a date set violates any date set previously entered. What I was looking for was that a date set could not be typed in as follows: 1/10/04 to 4/20/04 2/10/04 to 3/20/04 The second date set falls within the first set and should be invalid setting off a message or an alert of an invalid entry. I am interested in making it idiot proof so that one could not enter date sets within or covering dates sets already entered. This one really throws me, Please help. ...

How to auto fill fields on subform from data on main form?
To all, I have a Main form with multiple tabs, the form is for employee information, one of the tabs a has a subform where I'll record the names of the employees children if he/she has any. The subform will work if I make the datasheet use a lookup to the employee table, but then I have to select the employee each time I want to add a record in the children subform. I changed the children table to not use the lookup to clerks on the employee name. I had the subform working, (by working I mean, I manualy had to select the employee from the lookup) but I had the subform select the emplo...

Re: Using Text Styles
Front page will not have a Next Edition. AFAIK it is dead. > Ed Bennett wrote: > > Ron Hagley wrote: > >> I have a document with Headings on one line followed by a linespace > >> then on a new line a subheading followed by (on the same line ) a > >> description > >> > >> I wish to use TEXT STYLES as this pattern repeats many times, I have > >> no problem seting up the styles for the headings, but when I do the > >> same for the SUBHEADINGS the text style is applied to the WHOLE line > >> including the description...

Text in Cell as Formula #2
Peo + Julie Many thanks for your answer with the last query. I Have a similar question, please advise: This method [INDIRECT()] does work with values form a different spreadsheet. I type the link (as text) from a different spreadsheet in a cell in the current spreadsheet and use this method to call a value in a cell. Would appreciate a detailed answer (if complicated) - I'm a novice user! Many thanks in advance. ...

Logical Test: Text Against Number 01-05-10
Can anyone provide insight into how Excel treats this type of test? For example, why does Excel return TRUE when we have ="a">2 but FALSE when ="a"<2 (or any other number for that matter). Thanks. That's the way it is treated. Any kind of text is larger than the largest number. Any worth? hit the YES below -- Max Singapore --- "rslaughter5" wrote: > Can anyone provide insight into how Excel treats this type of test? For > example, why does Excel return TRUE when we have ="a">2 but FALSE when ="a"<2 ...

Rotate text?
Office(publisher) 2K. Is there anyway to rotate a specific word in a sentence? L. Not if it's part of the sentence rather than being a separate text box. -- JoAnn Paules MVP Microsoft [Publisher] "L." <ofallon12320@yahoo1.com> wrote in message news:%23TBzesS9FHA.2616@TK2MSFTNGP15.phx.gbl... > Office(publisher) 2K. > > Is there anyway to rotate a specific word in a sentence? > > L. > > Thanks for the info. L. "JoAnn Paules [MSFT MVP]" <jl_paules@hotmail.com> wrote in message news:U46dnd7PfZ5CTBHenZ2dnUVZ_sidnZ2d@suscom....