Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Breaking apart text

Status
Not open for further replies.

izachar

Technical User
Oct 7, 2000
84
0
0
CA
I have multiple drop downs so the user can select a month day and year to post a press release. I have to do this now in french. I created a dropdown with all the months in french and I am using the day and year from the original code. The problem is that when the user want to edit the field I need to break it down but now my existing code will not work because it is not a day/time field. Is there a way to break down a text field. If need be I will store delimiters like a comma to know where to separate?
 
If you can store your values using a delimiter like a ";", then you could use GetToken to extract the parts of your string.

<cfset datetimestring = &quot;jan;12;2001&quot;>

<cfset monthpart = GetToken(datetimestring, 1, &quot;;&quot;)>
<cfset daypart = GetToken(datetimestring, 2, &quot;;&quot;)>
<cfset yearpart = GetToken(datetimestring, 3, &quot;;&quot;)>

A &quot;token&quot; is just part of a string as defined by the delimiter. So month is token one, day is token two, and year is token three. John Hoarty
jhoarty@quickestore.com
 
to return specifis part of a date you can also use DatePart() function; the function will return the specified part of a date as an integer;

Syntax
DatePart(datepart, date)

datepart can be one of the following strings:

yyyy -- Year
q -- Quarter
m -- Month
y -- Day of year
d -- Day
w -- Weekday
ww -- Week
h -- Hour
n -- Minute
s -- Second

but if your code does not work because what you are saying that the filed in question is not a day/time field, than try using CreateDate() function

CreateDate: #CreateDate(2001, 8, 21)# Sylvano
dsylvano@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top