[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

Need to enter YYYY-MM-DD into MySQL table using.ASP script

Asked by PaulyWolly in Active Server Pages (ASP)

Tags: asp, isdate

This is code I found on the web to convert dates in ASP format that would normally be sent to an Access or MS SQL database, DD-MM-YYYY to a format that is compatible for MySQL which needs YYYY-MM-DD...

'====================
function mysqlDate( d, dir )
'====================
 'if not isDate( d ) then call errorMessage( d & " is not a date " )
 'if not isDate( d ) then exit function
 if not isDate( d ) then d = Date()
 
 dim strNewDate
 select case dir

  case 1 '=== store in db
  strNewDate = year( d ) & "-" & month( d ) & "-" & day( d )
 
  case 2 '=== use with asp
   strNewDate = month( d )& "/"  & day( d ) & "/" & year( d )
 end select

 strNewDate = cDate( strNewDate )
 mysqlDate = strNewDate
end function

'/////////////////////////////////////////
strDate = FormatDateTime(now())

strDay = Day(strDate)
If Len(strDay) = 1 Then
      strDay = "0" & strDay
End If

strMonth = Month(strDate)
If Len(strMonth) = 1 Then
      strMonth = "0" & strMonth
End If

strYear = DatePart("yyyy", strDate)

OutputDate = "('" & strYear & "-" & strMonth & "-" & strDay & "')"

'////////////////////////////////

Function dateConvert(conv_mode, conv_date)
      'convert date to and from ASP and MySQL date modes
      'i.e. ASP mode: MM/DD/YYYY; MySQL mode: YYYY-MM-DD
 
Dim newDate
 
If Not isDate(conv_date) Then conv_date = Date()
 
      Select Case conv_mode
Case 1 'resulting date will be in MySQL format
            newDate = year(conv_date) & "-" & month(conv_date) & "-" & day(conv_date)
       Case 2 'resulting date will be in ASP format
            newDate = month(conv_date) & "/" & day(conv_date) & "/" & year(conv_date)
End Select
 
newDate = CDate(newDate)
dateConvert = newDate

End Function

'//////////////////////////////////////////////////

I found this above code to convert dates being entered into MySQL table through .ASP page, but I am having such trouble trying to get a date entered in my MySQL table. I keep getting 0000-00-00 entered instead of my date.

here is more of my code:

'/////////////////
My Form:
'//////////////////
<form name='Upload' method='post' ENCTYPE='multipart/form-data' action='mysql_downloadadmin.asp?mode=uploadprocess'>
      <input type='hidden' name='txtDate' value='<%=date()%>'>
      <table width="121%" height="277" align="center" cellpadding="3">
      <tr>
        <td width="284" valign="top"><b>Select a file:</b><br>
        <input type='FILE' name='txtFile'>                    </td>
        <td width="18" valign="top">&nbsp;</td>
        <td width="336" valign="top"><b>Version:</b> <br>
          <input type='text' name='txtVersion'>                    </td>
      </tr>
      <tr>
        <td valign="top"><b>Title:</b><br>
          <input name='txtTitle' type='text' size="40">          <br>        </td>
        <td valign="top"><img src="../spacer.gif" width="18" height="32"></td>
        <td valign="top"><b>Access:</b><br>
          <select name="txtAccess">
            <option value=""> - Choose access level - </option>
            <option value="Internal">Internal</option>
            <option value="External">External</option>
            <option value="Development">Development</option>
            <option value="Private">Private</option>
          </select></td>
      </tr>
      <tr>
        <td height="42" colspan="2" valign="top"><b>Type:</b><br>
        <select name="txtSuffix">
          <option value=""> - Choose Type - </option>
              <option value="<%=strSuffix%>"><%=strSuffix%></option>
          <option value="Service Pack">SP</option>
          <option value="alpha">&alpha; - Alpha</option>
          <option value="beta">&beta; - Beta</option>
          <option value="RC">RC</option>
        </select>
        <input type='text' name='txSuffixText' size='3' value='<%=strSuffixText%>'>            
            </td>
        <td rowspan="3" valign="top"><b>Notes:</b><br>
            <textarea name='txtDescription' rows="5" cols="40"></textarea></td>
      </tr>
      <tr>
        <td height="45" colspan="2" valign="top"><strong>BAAN Product ID:</strong><br>
        <input type="text" name="txtBaanProdID"></td>
      </tr>
      <tr>
        <td height="6" colspan="2"><b>Author:</b> <br>
          <input type="text" name="txtAuthor"></td>
      </tr>
      <tr>
        <td><b>Group:</b> <br>
            <input type="text" name="txtGroup"></td>
        <td></td>
        <td>&nbsp;</td>
      </tr>
      <input type='hidden' name='txtID' value='<%=strID%>'>
      <tr>
        <td><div align="right">
            <INPUT name="image" type=image onClick='parent.history.back(); return false;' value='Back' src=images/back.gif align="middle">
        </div></td>
        <td><div align="center"> </div></td>
        <td><input type='image' src='images/submit.jpg' name='Submit2' value='Enter' alt='Enter'></td>
      </tr>
    </table>
</form>

'////////////////////////////////////////////////////////
Then my UploadProcess ASP works like this:
'///////////////////////////////////////////////////////

function fieldReplace(item)
 item = replace(item, "'", "''")
 item = replace(item, "%", "%")
 item = replace(item, vbcrlf, "<br>")
 fieldReplace = item
end function

If Request.querystring("mode") = "uploadprocess" then

    set adoCon = Server.CreateObject("ADODB.Connection")       
    adoCon.Open "Driver=" & dbDriver & "; Database=" & dbDatabase & "; Uid=" & dbUser & "; Pwd=" & dbPassword & ";"

      Set rsSettings = Server.CreateObject("ADODB.Recordset")
      strSettingsSQL = "SELECT sitelink FROM tblsettings"
      rsSettings.Open strSettingsSQL, adoCon

      Set Uploader = New FileUploader
      Uploader.Upload()

      strTitle = Uploader.Form("txtTitle")
      strDate = Uploader.Form("txtDate")
      strAuthor = Uploader.Form("txtAuthor")
      strAccess = Uploader.Form("txtAccess")
      strVersion = Uploader.Form("txtVersion")
      strDescription = Uploader.Form("txtDescription")
      strSuffix = Uploader.Form("txtSuffix")
      strSuffixText = Uploader.Form("txtSuffixText")
      strBaanProdID = Uploader.Form("txtBaanProdID")
      strGroup = Uploader.Form("txtGroup")
      
      
      strTitle = fieldReplace(strTitle)
      strDate = fieldReplace(strDate)
      strAuthor = fieldReplace(strAuthor)
      strAccess = fieldReplace(strAccess)
      strVersion = fieldReplace(strVersion)
      strDescription = fieldReplace(strDescription)
      strSuffix = fieldReplace(strSuffix)
      strSuffixText = fieldReplace(strSuffixText)
      strBaanProdID = fieldReplace(strBaanProdID)
      strGroup = fieldReplace(strGroup)
            

      If Uploader.Files.Count = 0 Then
            Response.Write "File(s) not uploaded."
      Else
            For Each File In Uploader.Files.Items
                  File.SaveToDisk Server.MapPath("files")
                  numSize = File.FileSize
                  strURL =  rsSettings("sitelink") & "/files/" & File.FileName
                  strSQL = "INSERT INTO tbldownload (downloadtitle, downloadDate, downloadsize, downloadAuthor, downloadAccess, downloadVersion, downloadSuffix, downloadSuffixText, downloadBaanProdID, downloadDescription, downloadurl, downloadGroup)VALUES('" & strTitle & "','" & strDate & "','" & numSize & "','" & strAuthor & "','" & strAccess & "','" & strVersion & "','" & strSuffix & "','" & strSuffixText & "','" & strBaanProdID & "','" & strDescription & "','" & strURL & "','" & strGroup & "')"
                  adoCon.Execute(strSQL)
            Next
      End If
      
      Set adoCon = Nothing
      Response.Redirect"mysql_downloadadmin.asp?mode=listdownload"
      
End If


I just want the date to be entered. This system needs to have a date when the file is added. All that I am getting in my date column in my database is 0000-00-00

I see the functions I found to convert dates and they look like they might work, but I don't know where to enter them into my code and how to enter them.

CAN ANYONE HELP!!!!


[+][-]12/27/05 11:47 PM, ID: 15561120Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Active Server Pages (ASP)
Tags: asp, isdate
Sign Up Now!
Solution Provided By: sherly
Participating Experts: 2
Solution Grade: B
 
[+][-]12/28/05 12:37 AM, ID: 15561260Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/28/05 07:29 AM, ID: 15562913Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/28/05 07:35 AM, ID: 15562965Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/29/05 10:13 PM, ID: 15576179Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]12/29/05 10:59 PM, ID: 15576300Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/02/06 11:07 PM, ID: 15596873Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81