Skip to main content
Participant
October 23, 2007
Question

Date formatting in MX7

  • October 23, 2007
  • 3 replies
  • 416 views
Hello, I am trying to upgrade my applications from v4.5 to MX 7. The application seems to have issues with handling date fields. The dates are saved in the database correctly, however, when the app pulls it from the database, displays it with timestamp symbols like '{ts' 10-23-2007 00:00:00'}' instead of just saying 10-23-2007. As per one of the members' advise, I checked the option that says 'display date as string' on the advanced ODBC settings for the data source in ColdFusion Administrator. Still doesn't make a difference. Any help please? Thanks, Jay.
    This topic has been closed for replies.

    3 replies

    Inspiring
    October 23, 2007
    Most of my issues were with select queries and displaying the results. There were at least two available solutions, and I used both.

    Solution 1

    instead of
    select somedatefield
    do
    select some_function_that_converts_dates_to_strings(somedatefield)

    Solution 2
    instead of
    #somedatefield#
    do
    #DateFormat(somedatefield, "mask")#
    Inspiring
    October 23, 2007
    You have to re-write all your templates, just like I had to.
    CatJayAuthor
    Participant
    October 23, 2007
    Hello Dan, Could you explain me a bit more please? What part of the templates should be re-written and how etc? Sounds like you have run into same issue also with your applications. I am not a CF developer, I just started supporting the existing apps and picked up bits and pieces of CF. If you can explain me how to get this fixed, would really appreciate. Thanks, Jay.
    Participating Frequently
    October 23, 2007
    The code on the front-end could be updated to use the dateFormat() function.
    Alternatively, you could update the queries to format the date.

    I'm guessing that this is more of a database driver issue, than a ColdFusion version issue. As part of your upgrade to CFMX 7, you're likely using different database drivers as well. It's possible that the old database drivers were formatting and truncating these date values for you. So the front-end code could be "lazy" and no worry about formatting.

    Really the best fix here is going to be updating the front-end to format the date values as it bests sees fit. (assuming some of my above assumptions are correct)

    Best of luck.