blob150
asked on
ASP & MYSQL Date formatting problems
I am having date formatting problems with ASP and MYSQL. The date is stored as yyyy-mm-dd in MYSQL but displays as mm/dd/yy when I pull a recordset in Dreamweaver. This is causing a problem when I try to setup and update page because the current record displays in mm/dd/yy format and when the update is submitted MYSQL does not read it properly.
Can someone tell me how to either store the dates in MYSQL as mm/dd/yy, or display them as yyyy-mm-dd so they are consistent? I tried to use the Date_Format function in the Select statement and that worked great when I run the query directly, but when I post the page I get and invalid character error for "%". Here is the SQL statement. If I could get thios to work - problem solved.
SELECT arm.deals.Investor_ID, Pro_ID, Pro_AdminStat, Property_Address1, Property_Address2, Property_Address3, Property_City, Property_State, Property_Zip, DATE_FORMAT(Ext_Date, "%Y-%m-%d") as Ext_Date, Add_Bonus, Settled_Date, Notes, Total_Amt, Pro_DescriptFooter, arm.investors.Investor_ID, Inv_email, Inv_Contact, Pro_DateMod
FROM arm.deals, arm.property_info, arm.investors
WHERE Pro_ID = MMColParam AND arm.deals.Property_ID = arm.property_info.Property _ID AND arm.deals.Investor_ID = arm.investors.Investor_ID
Any help is appreciated. Thanks.
Can someone tell me how to either store the dates in MYSQL as mm/dd/yy, or display them as yyyy-mm-dd so they are consistent? I tried to use the Date_Format function in the Select statement and that worked great when I run the query directly, but when I post the page I get and invalid character error for "%". Here is the SQL statement. If I could get thios to work - problem solved.
SELECT arm.deals.Investor_ID, Pro_ID, Pro_AdminStat, Property_Address1, Property_Address2, Property_Address3, Property_City, Property_State, Property_Zip, DATE_FORMAT(Ext_Date, "%Y-%m-%d") as Ext_Date, Add_Bonus, Settled_Date, Notes, Total_Amt, Pro_DescriptFooter, arm.investors.Investor_ID,
FROM arm.deals, arm.property_info, arm.investors
WHERE Pro_ID = MMColParam AND arm.deals.Property_ID = arm.property_info.Property
Any help is appreciated. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And I putted Session.LCID = 1053 (for sweden) in top of the script, then it's formatted the dates correct.
ASKER
Thank you for the quick response. Clearly I am an amateur at this stuff, and where I can follow the logi in what you posted, I am not sure how or where to integrate it on my page. If you can point me in the right direction there I should be in good shape and I'll boost the point total a little. The variable in questions is Ext_Date. Here is the code for the page:
<%@LANGUAGE="VBSCRIPT"%>
<%Option Explicit%>
<!--#include file="../Connections/Deals
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariabl
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")
MM_editConnection = MM_Deals_STRING
MM_editTable = "arm.deals"
MM_editColumn = "Pro_ID"
MM_recordId = "" + Request.Form("MM_recordId"
MM_editRedirectUrl = "email_deal_change.asp"
MM_fieldsStr = "ProAdminStat|value|ext_da
MM_columnsStr = "Pro_AdminStat|',none,''|E
' 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_field
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.Form <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.Form <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.Form
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.Form
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),"
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB
MM_editCmd.ActiveConnectio
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnectio
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editR
End If
End If
End If
%>
<%
Dim Rs_Update__MMColParam
Rs_Update__MMColParam = "310"
If (Request.QueryString("Pro_
Rs_Update__MMColParam = Request.QueryString("Pro_I
End If
%>
<%
Dim Rs_Update
Dim Rs_Update_numRows
Set Rs_Update = Server.CreateObject("ADODB
Rs_Update.ActiveConnection
Rs_Update.Source = "SELECT arm.deals.Investor_ID, Pro_ID, Pro_AdminStat, Property_Address1, Property_Address2, Property_Address3, Property_City, Property_State, Property_Zip, Ext_Date, Add_Bonus, Settled_Date, Notes, Total_Amt, Pro_DescriptFooter, arm.investors.Investor_ID,
Rs_Update.CursorType = 0
Rs_Update.CursorLocation = 2
Rs_Update.LockType = 1
Rs_Update.Open()
Rs_Update_numRows = 0
%>
<!--#INCLUDE file="../adovbs.inc" -->
<!--#INCLUDE file="../dbFuncs.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Alliance Resource Management, LLC</title>
<!-- STYLESHEET -->
<link href="../css/main.css" rel="stylesheet" type="text/css">
<link href="../css/admincss.css"
<!-- JAVASCRIPT -->
<script src="../js/arm.js" type="text/javascript"></s
<!-- META TAGS -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta name="keywords" content="Real Estate, Rent, Rental, Lease Purchase, Investor, Alliance Resource Management, Atlanta, Gwinnett, Dekalb">
<meta name="description" content="Alliance Resource Management, LLC">
<meta name="author" content="Alliance Resource Management, LLC">
<meta name="copyright" content="2005">
<script type="text/JavaScript">
<!--
function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
var a=YY_checkform.arguments,o
for (i=1; i<a.length;i=i+4){
if (a[i+1].charAt(0)=='#'){r=
o=MM_findObj(a[i].replace(
o1=MM_findObj(a[i+1].repla
v=o.value;t=a[i+2];
if (o.type=='text'||o.type=='
if (r&&v.length==0){err=true}
if (v.length>0)
if (t==1){ //fromto
ma=a[i+1].split('_');if(is
} else if (t==2){
rx=new RegExp("^[\\w\.=-]+@[\\w\\
} else if (t==3){ // date
ma=a[i+1].split("#");at=v.
if(at){
cd=(at[ma[1]])?at[ma[1]]:1
dte=new Date(cy,cm,cd);
if(dte.getFullYear()!=cy||
}else{err=true}
} else if (t==4){ // time
ma=a[i+1].split("#");at=v.
} else if (t==5){ // check this 2
if(o1.length)o1=o1[a[i+1].
if(!o1.checked){err=true}
} else if (t==6){ // the same
if(v!=MM_findObj(a[i+1]).v
}
} else
if (!o.type&&o.length>0&&o[0]
at = a[i].match(/(.*)\[(\d+)\].
o2=(o.length>1)?o[at[2]]:o
if (t==1&&o2&&o2.checked&&o1&
if (t==2){
oo=false;
for(j=0;j<o.length;j++){oo
if(!oo){s+='* '+a[i+3]+'\n'}
}
} else if (o.type=='checkbox'){
if((t==1&&o.checked==false
} else if (o.type=='select-one'||o.t
if(t==1&&o.selectedIndex/1
}else if (o.type=='textarea'){
if(v.length<a[i+1]){err=tr
}
if (err){s+='* '+a[i+3]+'\n'; err=false}
}
if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
document.MM_returnValue = (s=='');
}
//-->
</script>
</head>
<body bgcolor="#004D91">
<a href="../index.htm"><img src="../images/ARM_logo_mi
<div id="back">Main Admin page / <a href="../index.htm">Home</
</div>
<div id="header"> Update Deal For Investor #: <span class="title_data"><%=(Rs_
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="50%"><form ACTION="<%=MM_editAction%>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="adminrowlabel">Proj
<td><%=(Rs_Update.Fields.I
</tr>
<tr>
<td class="adminrowlabel">Stat
<td><select name="ProAdminStat" id="ProAdminStat">
<option value="Active" <%If (Not isNull((Rs_Update.Fields.I
<option value="Settled" <%If (Not isNull((Rs_Update.Fields.I
</select></td>
</tr>
<tr>
<td width="22%" class="adminrowlabel">Exte
<td width="28%"><input name="ext_date" type="text" id="ext_date" value="<%=(Rs_Update.Field
</tr>
<tr>
<td class="adminrowlabel">Addi
<td><input name="Add_Bonus" type="text" id="Add_Bonus" value="<%=(Rs_Update.Field
</tr>
<tr>
<td class="adminrowlabel">Sett
<td><input name="Settled_Date" type="text" id="Settled_Date" value="<%=(Rs_Update.Field
</tr>
<tr>
<td class="adminrowlabel">Tota
<td><input name="Total_Amount" type="text" id="Total_Amount" value="<%=(Rs_Update.Field
</tr>
<tr>
<td valign="top" class="adminrowlabel">Note
<td><textarea name="Notes" id="Notes"><%=(Rs_Update.F
</tr>
<tr>
<td valign="top" class="adminrowlabel">Date
<span class="tiny2">(This will be updated with today's date) </span></td>
<td><%=(Rs_Update.Fields.I
</tr>
<tr>
<td height="41"> </td>
<td><input type="submit" name="Submit" value="Update Deal" />
<input name="email" type="hidden" id="email" value="<%=(Rs_Update.Field
<input name="name" type="hidden" id="name" value="<%=(Rs_Update.Field
<input name="address1" type="hidden" id="address1" value="<%=(Rs_Update.Field
<input name="address2" type="hidden" id="address2" value="<%=(Rs_Update.Field
<input name="address3" type="hidden" id="address3" value="<%=(Rs_Update.Field
<input name="number" type="hidden" id="number" value="<%=(Rs_Update.Field
<input name="dat_mod" type="hidden" id="dat_mod" value="<%=Now()%>" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= Rs_Update.Fields.Item("Pro
</form> </td>
<td width="50%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="34%" valign="top" class="adminrowlabel">Prop
<td width="66%"><%=(Rs_Update.
<%=(Rs_Update.Fields.Item(
<%=(Rs_Update.Fields.Item(
</tr>
<tr>
<td valign="top" class="adminrowlabel">City
<td><%=(Rs_Update.Fields.I
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<%
Rs_Update.Close()
Set Rs_Update = Nothing
%>