moiseszaragoza
06-28-2009, 03:27 PM
I have a date 08-22-1983 and i need to spit it into 3 part
08
22
1983
Any ides how do do this?
Thanks
08
22
1983
Any ides how do do this?
Thanks
|
Click to See Complete Forum and Search --> : Explode, Split moiseszaragoza 06-28-2009, 03:27 PM I have a date 08-22-1983 and i need to spit it into 3 part 08 22 1983 Any ides how do do this? Thanks WolfShade 07-02-2009, 02:12 PM You can use either getToken() or ListGetAt(). Say your date is a variable. Then set the date format how you want it. <cfset thisDate = DateFormat(now(),'mm-dd-yyyy')> This will display as "07-02-2009". Use the "-" as a delimiter. <cfset thisMonth = getToken(thisDate,1,"-")> <cfset thisMonth = ListGetAt(thisDate,1,"-")> Both examples pretty much do the same thing. Get value in first position of a list that is delimited by a hyphen. Then do the same for day and year: <cfset thisMonth = getToken(thisDate,1,"-")> <cfset thisMonth = ListGetAt(thisDate,1,"-")> <cfset thisDay = getToken(thisDate,2,"-")> <cfset thisDay = ListGetAt(thisDate,2,"-")> <cfset thisYear = getToken(thisDate,3,"-")> <cfset thisYear = ListGetAt(thisDate,3,"-")> ^_^ moiseszaragoza 07-15-2009, 12:46 AM Thanks alot for all your help, you would not know how many (-) are in the string? incase i would not have a fix number or spacers? moiseszaragoza 07-15-2009, 01:19 AM <cfset SplitVar = #URL.modelID# /> <cfquery datasource="XXXXXXX" dbname="XXXXXX" name="get_memb"> SET QUOTED_IDENTIFIER OFF INSERT INTO ModelToPart (modelID,ModelPartID) VALUES <cfloop index="intI" from="1" to="#(ListLen( SplitVar, ',' )-1)#" step="1"> <cftry> ('#URL.modelID#',' #ListGetAt( SplitVar, intI+1, "," )#') , <cfcatch> ERROR: #CFCATCH.Message# </cfcatch> </cftry> </cfloop> </cfquery> <cflocation url="http://www.modelproductions.com/book_NweProjct_viewPart.cfm?modelProjectID=#URL.modelProjectID#"> I am using the code above to create a Query that inserts multiple records. Buy I have a extra coma at the end. how can i have it that the last coma does not sohw Thanks WolfShade 07-15-2009, 04:56 PM Are you using a loop to create the list with var = var & "data," (thereby putting a comma at the end of the value with each iteration)? Or are you using ListAppend()? ListAppend() will not put the last comma in there. A loop will, unless you know how many iterations there are, in which case you can set a conditional to NOT put the comma in there on the last iteration. ListAppend() is the best option, though. ^_^ moiseszaragoza 07-16-2009, 12:47 AM Thanks 1000 you dont know how much you help me webdeveloper.com
Copyright WebMediaBrands Inc., All Rights Reserved. |