Some dates work, some dates dont

Discussion in 'Programming' started by vanderkerkoff, Oct 24, 2006.

  1. #1
    I'm getting a wierd problem with dateformat

    Can anyone tell me why this dateformat string works



    #DATEFORMAT("Mon, 23 Oct 2006 07:04 CDT", "m/d/")#
    I get 10/23

    While this one
    #DATEFORMAT("Wed, 18 Oct 2006 07:40 CDT", "m/d/")#

    gives me this java error
    Parameter validation error for function DATEFORMAT.

    The value of the parameter 1, which is currently "Wed, 18 Oct 2006 07:40 CDT", must be a class java.util.Date value.

    I'm ouputting some dates from an rss feed and some dates work, and some don't, while they are all in the same format?

    Any help will be greatly appreciated.
     
    vanderkerkoff, Oct 24, 2006 IP
  2. seamus.hogan

    seamus.hogan Peon

    Messages:
    31
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi the problem seems to be all the other text so you can try stripping it all out as below

    <cfoutput>
    <!--- set the two dates --->
    <cfset date[1] = "Mon, 23 Oct 2006 07:04 CDT">
    <cfset date[2] = "Wed, 18 Oct 2006 07:40 CDT">
    <cfscript>
    // this just loops over the two dates
    loop = 1;
    while (loop LE 2)
    {
    // delete any occurences of weekdays or CDT from the dates
    date[loop] = replacelist(DATE[loop],"Mon,Tue,Wed,Thur,Fri,Sat,Sun, CDT, x", "");
    // delete any commas
    date[loop] = Replace(date[loop], chr(44), '');
    loop = loop + 1;
    }
    </cfscript>

    <!--- output and format the remaining text as dates --->
    date1 is #DATEFORMAT(date[1])#
    <br>
    date2 is #DATEFORMAT(date[2])#


    </cfoutput>

    Hope this helps

    Seamus
     
    seamus.hogan, Oct 26, 2006 IP