A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

extract date from text field



 
 
Thread Tools Display Modes
  #1  
Old July 13th, 2009, 05:06 PM posted to microsoft.public.access
Sparky
external usenet poster
 
Posts: 26
Default extract date from text field

Hello,
I am new to access (2003) so may not use the correct terminology.

I want to extract a 'date' from a text field to populate another field. As
well I need to extract a string of numbers to fill another field.

SceneID=catDALI_a2155342430807171842022J_a26S5G2J2 00807171841140LMLMMX_satShift0_seg5278220.

The KJ to extract is 534243
The SceneDate to extract is 080717

The SceneID will always have the same structure.
  #2  
Old July 13th, 2009, 05:31 PM posted to microsoft.public.access
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default extract date from text field

If you just want 080717:

SceneDate: Mid([SceneID],19,6)

If you want an actual date the following should work assuming that SceneDate
080717 is 7/17/2008:

SceneDate: CDate(Mid([SceneID],21,2) & "/" & Mid([SceneID],23,2) & "/" &
Mid([SceneID],19,2))

I'm also assuming that the string always has the same number of characters
in the same order. Plus the date part of the string will always be a valid
date. CDate chokes on an invalid date.

KJ: Mid([SceneID],13,6)
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"Sparky" wrote:

Hello,
I am new to access (2003) so may not use the correct terminology.

I want to extract a 'date' from a text field to populate another field. As
well I need to extract a string of numbers to fill another field.

SceneID=catDALI_a2155342430807171842022J_a26S5G2J2 00807171841140LMLMMX_satShift0_seg5278220.

The KJ to extract is 534243
The SceneDate to extract is 080717

The SceneID will always have the same structure.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.