Bl**dy date problems!

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Bl**dy date problems!

    I have table "games" and I am currently creating a page to update existing
    records:

    I have first page which lists games available for amending:


    <cfquery name="open_games" datasource="PokerLeague">
    SELECT gameID, gameReference, GameTitle, gameBuyin, gameDate, gameTime
    FROM games
    WHERE gameStatus = 'open'
    ORDER BY gameDate, gameTime
    </cfquery>

    <cfoutput query="open_games">
    <tr>
    <td width="75" height="20" align="left" valign="middle"
    style="padding-left: 15px">
    <font class="dspTxt01">#gameReference#</font>
    </td>
    <td width="200" height="20" align="left" valign="middle">
    <font class="dspTxt01">#gameTitle#</font>
    </td>
    <td width="75" height="20" align="left" valign="middle">
    <font class="dspTxt01">#gameBuyin#</font>
    </td>
    <td width="75" height="20" align="left" valign="middle">
    <font class="dspTxt01">#DateFormat(gameDate,
    "dd/mm/yyyy")#</font>
    </td>
    <td width="75" height="20" align="left" valign="middle">
    <font class="dspTxt01">#TimeFormat(gameTime,
    "HH:mm")#</font>
    </td>
    <td width="100" height="20" align="left" valign="middle">
    <a href="amend_game.cfm?id=#gameID#"
    class="dspTxt02">Amend...</a>
    </td>
    <td width="100" height="20" align="left" valign="middle">
    <a href="close_game.cfm?id=#gameID#"
    class="dspTxt02">Close...</a>
    </td>
    <td width="100" height="20" align="left" valign="middle">
    <a href="delete_game.cfm?id=#gameID#"
    class="dspTxt02">Delete...</a>
    </td>
    </tr>
    </cfoutput>



    I then have 2nd page which dislays existing values in form for updating once
    game selected on original page:


    <cfquery name="selected_game" datasource="PokerLeague">
    SELECT gameID, gameReference, GameTitle, gameBuyin, gameDate, gameTime
    FROM games
    WHERE gameID = #URL.id#
    </cfquery>

    <cfoutput query="selected_game" maxrows="1">
    <cfform name="amend" action="amend_game_process.cfm">
    <input type="hidden" name="gameID" value="#gameID#">
    <table width="300" height="165">
    <tr>
    <td width="100" height="25" align="left"
    valign="middle">
    <font class="dspTxt01">Reference:</font>
    </td>
    <td width="200" height="25" align="left"
    valign="middle">
    <cfinput type="text" name="gameReference"
    value="#gameReference#" class="dspTxt01" style="width: 200px" required="yes"
    message="You must enter a Reference!">
    </td>
    </tr>
    <tr>
    <td width="100" height="25" align="left"
    valign="middle">
    <font class="dspTxt01">Title:</font>
    </td>
    <td width="200" height="25" align="left"
    valign="middle">
    <cfinput type="text" name="gameTitle"
    value="#gameTitle#" class="dspTxt01" style="width: 200px" required="yes"
    message="You must enter a Title!">
    </td>
    </tr>
    <tr>
    <td width="100" height="25" align="left"
    valign="middle">
    <font class="dspTxt01">Buy In:</font>
    </td>
    <td width="200" height="25" align="left"
    valign="middle">
    <cfinput type="text" name="gameBuyin"
    value="#gameBuyin#" class="dspTxt01" style="width: 200px" required="yes"
    message="You must enter a Buy In!">
    </td>
    </tr>
    <tr>
    <td width="100" height="25" align="left"
    valign="middle">
    <font class="dspTxt01">Date:</font>
    </td>
    <td width="200" height="25" align="left"
    valign="middle">
    <cfinput type="text" name="gameDate"
    value="#DateFormat(gameDate, 'dd/mm/yyyy')#" class="dspTxt01" style="width:
    200px" required="yes" message="You must enter a Date!">
    </td>
    </tr>
    <tr>
    <td width="100" height="25" align="left"
    valign="middle">
    <font class="dspTxt01">Time:</font>
    </td>
    <td width="200" height="25" align="left"
    valign="middle">
    <cfinput type="text" name="gameTime"
    value="#TimeFormat(gameTime, 'HH:mm')#" class="dspTxt01" style="width: 200px"
    required="yes" message="You must enter a Time!">
    </td>
    </tr>
    <tr>
    <td width="300" height="40" colspan="2"
    align="right" valign="bottom">
    <input type="submit" value="Amend..."
    class="dspTxt01">
    </td>
    </tr>
    </table>
    </cfform>
    </cfoutput>



    Then final page that updates record:


    <cfquery name="update_game" datasource="PokerLeague">
    UPDATE games
    SET gameReference = #FORM.gameReference#, gameTitle = '#FORM.gameTitle#',
    gameBuyin = '#FORM.gameBuyin#', gameDate = #CreateODBCDate(FORM.gameDate)#,
    gameTime = #createODBCTime(FORM.gameTime)#
    WHERE gameID = #FORM.gameID#
    </cfquery>



    The problem I am getting is the date, once I have processed an amendment (with
    or without a date change) the query update is processing the date in the wrong
    format and so is entering into the record with the day and month numbers the
    wrong way round, ie 10/07/2005 is ending up as 07/10/2005.

    I am using MS Access as my database and the date field is saved as type
    Date/Time with General Date format.

    What should I do to retain the correct date format?

    DJCull Guest

  2. Similar Questions and Discussions

    1. Searching by date problems
      hello I am trying to write a query that searches my access database by date, here is the scenario: Two text fields on the page that submit to...
    2. problems with date
      Hi, having a small problem in a trigger i want to automatically update a date field but when i use for example update table set field =...
    3. problems with Date-Calc
      I am trying to install Date-Calc-5.3 on a redhat 7.3 box with perl 5.8. During the make test I keep getting the following error. .......
    4. Date Problems
      Hi all, I have racked my brain on this and can't come up with a solution. I have a table in SQL Server called - it holds dates in a field called ...
    5. Having problems with a date field
      Happy New Year Everybody! I am having problems when trying query an access database that has a couple of date/time fields. If I construct my...
  3. #2

    Default Re: Bl**dy date problems!

    you not actually creating a date, you just inserting a actual date that games has been played. can you use this instead: #DateFormat(FORM.gameDate, "mm/dd/yy")#
    cfmlgirl Guest

  4. #3

    Default Re: Bl**dy date problems!

    This is because your using the "English" date format as opposed to the US
    format that CF expects.

    You can use setlocale to change this, but I have never got it to work as I
    would like.

    I now build the dates from the forms I have. You know that the date will be
    entered in a certain format "dd/mm/yyyy"

    CreateODBCDate(CreateDate(ListLast(FORM.gameDate, "/"), Mid(FORM.gameDate, 4,
    2), ListFirst(FORM.gameDate, "/"))

    cfmlgirl FYI
    It is recommended that you never use date display function to insert into a
    database, mainly I think because of the problems (as per this post)

    Ken



    The ScareCrow Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139