Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date problem

Status
Not open for further replies.

redbay

Technical User
Oct 13, 2003
145
GB
Hi

I have an input form and one of the fields is date (=Date()& short format-ddmmyy) this works Ok in the input form but i then have an update form and once that is updated the date is saved as mmddyy and then doesnt become the last entry. i have checked all my dates and they are set as they should but what could possibly be chamging this?
 
The database, have a look at the faqs for a method of reformatting the date

Cheech

[Peace][Pipe]
 
The database is OK because when i insert a recor using my insert form dates go in OK (01/06/2005) but when i update the record in my update record form it sends it back to the database as 06/01/2005
 
Can you post some code?

I don't think you'd get much help without more information...

[cheers]
Cheers!
Laura
 
<input type="text" name="ComplaintDate" value="<%=(rsProblems.Fields.Item("ComplaintDate").Value)%>" size="32">
 
I'm still having problems with this date, i've now found that its only with dates from the 1st to the 9th of each month, for example any records dated 27/05/2005 when updated stay as that date but anything dated as 01/06/2005 updates as 06/01/2005 i'm starting to pull my hair out with this......
 
I guess you are using access then. LOOK AT THE FAQ in the DW/Ultradev form

[Peace][Pipe]
 
Cheech,
thanks for your help (AGAIN!). tried your code but that didnt work, i've now decided i think its how i've set the update form as i have another and that works fine. this is the code in the form

<form method="post" action="<%=MM_editAction%>" name="form1">
<table>
<tr valign="baseline">
<td nowrap align="right">Complaint Date:</td>
<td> <input type="text" name="ComplaintDate" value="<%=(rsProblems.Fields.Item("ComplaintDate").Value)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Category:</td>
<td> <input type="text" name="Category" value="<%=(rsProblems.Fields.Item("Category").Value)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Short Desc:</td>
<td> <input type="text" name="ShortDesc" value="<%=(rsProblems.Fields.Item("ShortDesc").Value)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Full Desc:</td>
<td> <input type="text" name="FullDesc" value="<%=(rsProblems.Fields.Item("FullDesc").Value)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td> <input type="submit" value="Save"> </td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= rsProblems.Fields.Item("ComplaintID").Value %>">
</form>

Thanks again
 
Code:
<%
Dim strUKDate, MYdd, MYmm, MYyy
MYdd = DatePart("d", rsProblems.Fields.Item("ComplaintDate").Value)
MYmm = DatePart("m", rsProblems.Fields.Item("ComplaintDate").Value)
MYyy = DatePart("yyyy", rsProblems.Fields.Item("ComplaintDate").Value)
strUKDate = (MYdd & "/" & MYmm & "/" & MYyy)
%>

<form method="post" action="<%=MM_editAction%>" name="form1">
  <table>
    <tr valign="baseline"> 
      <td nowrap align="right">Complaint Date:</td>
      <td> <input type="text" name="ComplaintDate" value="<%=strUKDate%>" size="32"> 
      </td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right">Category:</td>
      <td> <input type="text" name="Category" value="<%=(rsProblems.Fields.Item("Category").Value)%>" size="32"> 
      </td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right">Short Desc:</td>
      <td> <input type="text" name="ShortDesc" value="<%=(rsProblems.Fields.Item("ShortDesc").Value)%>" size="32"> 
      </td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right">Full Desc:</td>
      <td> <input type="text" name="FullDesc" value="<%=(rsProblems.Fields.Item("FullDesc").Value)%>" size="32"> 
      </td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right">&nbsp;</td>
      <td> <input type="submit" value="Save"> </td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="MM_recordId" value="<%= rsProblems.Fields.Item("ComplaintID").Value %>">
</form>

[Peace][Pipe]
 
Cheech

i copied and pasted the code and it still doesnt work....i've now found out that it only affects dates from 1st to the 12th of each month, they go in to the db ok but update incorrect
 
Cheech

found the following piece of code in dmx zone and after changing the standard to english it works fine - thanks for all your help

Then, insert these two pieces of code in the head of your asp-page:

' Set your LCID here. For instance, '1033' is US-English regional setttings (default)
<% Session.LCID = 1043 'Dutch regional setttings %>



<%
Function IsoDate(dteDate)
'Version 1.0 by Giuliano Sauro
If IsDate(dteDate) = True Then
DIM dteDay, dteMonth, dteYear
dteDay = Day(dteDate)
dteMonth = Month(dteDate)
dteYear = Year(dteDate)
IsoDate = dteYear & _
"-" & Right(Cstr(dteMonth + 100),2) & _
"-" & Right(Cstr(dteDay + 100),2)
Else
IsoDate = Null
End If
End Function%>



And finally, find this piece of standard Dreamweaver insert/update form-record code, and insert the red code.


MM_fieldsStr = "order|value|number|value|orderdate|value"
MM_columnsStr = "order|',none,''|number|',none,''|orderdate|#,none,NULL"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
'--convert date to ISO date-format
If IsDate(MM_fields(MM_i+1)) Then
MM_fields(MM_i+1) = IsoDate(MM_fields(MM_i+1))
End If
'--
Next

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top