#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    70
    Rep Power
    0

    French date format


    Assuming date(NOW) is December 18, 2010 ...
    <cfset frenchMonths = "janvier,février,marcher,avril,juin,juillet,août,septembre,octobre,novembre,décembre">

    <cfset date = DateFormat(Now(), "m d yy")>
    <cfset fMonth = ListGetAt(frenchMonths, ListGetAt(date, 1, " "))>
    <cfset frenchDate = ListSetAt(date, 1, fMonth, " ")>

    <cfoutput>#frenchDate#</cfoutput>

    will give you this output:

    décembre 18 10 ....

    What would format be to display date as 18 décembre 10 ? Changing only dateformat throws List error .... help appreciated .... LSdateformat is not an option as data is not formatted as "date"

    Thanks
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,269
    Rep Power
    968
    I'm not sure what you mean about it "not being formatted as date". Why can't you use LSDateFormat()? Formatting a date in a specific locale is exactly what it is for.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    70
    Rep Power
    0
    Originally Posted by kiteless
    I'm not sure what you mean about it "not being formatted as date". Why can't you use LSDateFormat()? Formatting a date in a specific locale is exactly what it is for.
    The following works fine for datatype "date/time" - for a number of reasons the datatype needs to be TEXT - LSDateformat does not work with TEXT dates, a cannot convert error occurs with LSDateformat ... the code I posted works fine with TEXT data, just need the day to appear before the month.

    <cfset oldlocale = SetLocale("French (Standard)")>
    #LSDateFormat(Pastmfn.Udate, "dd mmmm, yyyy")#
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,269
    Rep Power
    968
    ColdFusion is typeless, so there is no "date/time" type. The date functions just expect the date string to be in a format that it can process.

    In any event, if doing

    ListSetAt(date, 1, fMonth, " ")

    gives you: décembre 18 10 ....

    Then can't you just do this to set the month at the second list position instead of the first?

    ListSetAt(date, 2, fMonth, " ")

    Edit: ah never mind I see what you're doing now. Can you use ListInsertAt() to insert the month as the third list element?
    Last edited by kiteless; March 16th, 2011 at 02:26 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    70
    Rep Power
    0
    I understood it was typeless as well ... just doesn't work unless datatype is ATE - just tested by changing datatype to DATE - works fine ...

    changed datatype back to text ... this works: #LSDateFormat((dateFormat(Pastmfn.Udate, "dd/mm/yyyy")),"dd/mmm/yyyy")#

    above code changes the dates that the DB sends to the correct format.

    Some hunting around and seems there is a lot of problem with dates and datatype .... thanks for the replies.
  10. #6
  11. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,269
    Rep Power
    968
    Originally Posted by frapple
    this works: #LSDateFormat((dateFormat(Pastmfn.Udate, "dd/mm/yyyy")),"dd/mmm/yyyy")#
    Yes that's exactly what I meant about using LSDateFormat and just getting your value into a valid date format.

    Originally Posted by frapple
    Some hunting around and seems there is a lot of problem with dates and datatype .... thanks for the replies.
    Not really. CF is actually really forgiving in that it can handle a LOT of different date formats. But yes, that list isn't all-encompassing, so in certain situations you do need to modify the string.

IMN logo majestic logo threadwatch logo seochat tools logo