Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7724997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:49:43+00:00 2026-06-01T04:49:43+00:00

Grabbing delimited dates from database and adding new ones to the list, then want

  • 0

Grabbing delimited dates from database and adding new ones to the list, then want to put all dates in correct order of the date.

<cfparam default="" name="newDates">
<cfloop index="tm" from="#form.arrive#" to="#form.depart#" step="#createTimespan(1,0,0,0)#">    

<cfset newDates = newDates & '#dateFormat( tm, "mm/dd/yyyy" )#,'>

</cfloop>
<cfset penddate = '#pmonthlist#, #newDates#'>

How Can I take the results of this.

7/15/2012,7/16/2012,7/17/2012,7/18/2012,7/19/2012,7/20/2012,7/21/2012,9/21/2012,9/22/2012,9/28/2012,9/29/2012, 04/01/2012,04/02/2012,04/03/2012,04/04/2012,04/05/2012,04/06/2012,04/07/2012,

And make it into the correct date order like this. (this is the results I want)

04/01/2012,04/02/2012,04/03/2012,04/04/2012,04/05/2012,04/06/2012,04/07/2012,7/15/2012,7/16/2012,7/17/2012,7/18/2012,7/19/2012,7/20/2012,7/21/2012,9/21/2012,9/22/2012,9/28/2012,9/29/2012

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:49:44+00:00Added an answer on June 1, 2026 at 4:49 am

    UPDATE: Solution #0 – just sort them using arraySort(dates, 'numeric') (doesn’t work in Railo), see: http://www.cfgears.com/index.cfm/2010/10/7/Using-an-array-to-sort-dates

    Solution #1 – sort an array of dates

    1. Turn the list of dates into an array using ListToArray()
    2. loop through the array and DateFormat() them as YYYYMMDD
    3. ArraySort(dates, 'numeric')
    4. loop through the dates again and DateFormat() them back to M/D/YYYY
    5. ArrayToList()

    Solution #2 – use Query of Queries

    1. if you have a query object with records of dates, skip to step 2.
    2. set myQuery as QueryNew(‘MyDate’,’Date’)
    3. loop through the dates, and add them into the query using QueryAddRow() and QuerySetCell()
    4. use Query of Queries: SELECT MyDate FROM myQuery ORDER BY MyDate
    5. ValueList(myQuery.myDate)

    Solution #3 – use Java

    1. turn list of dates into an array
    2. loop through the array, use javacast to cast each date as java.util.Date
    3. invoke sort() in java.util.Collections on the array

    Solution #4 – use DateCompare()

    1. turn list of dates into an array
    2. write your own sorting algorithm (insertion sort? bubble sort?), using DateCompare() to compare dates.

    Solution #5 – use DB temp table

    1. insert into a temp table
    2. select them out using ORDER BY
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm grabbing some JSON from YQL, parsing it into a list. Then I want
I'm grabbing all the filenames from a directory and I want to create a
I'm grabbing data from a published google spreadsheet, and all I want is the
Rather than just grabbing the user's friends' emails, I want to show their list
When I am grabbing data from my table that require permissions, should all the
I am grabbing the time from a list of ids. Not every id has
I am grabbing posts from the WordPress database using this piece of code: $query
I'm grabbing some information from a database and the record is in an MSSQL
I am grabbing an HTMLElement from a browser object and then using getElementById to
I have this syntax for grabbing some data from database, I using codeigniter's active

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.