User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 374,020 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,742 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1534 | Replies: 4
Reply
Join Date: Jul 2006
Posts: 9
Reputation: GavinC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
GavinC GavinC is offline Offline
Newbie Poster

Help Help with dates please

  #1  
Jul 24th, 2006
Hi there all.

I have a problem with a date situation. I have a form that needs to look for a specified date in an Access database. I have managed to do the following:

1. When the date is enterd it is entered as follows
"2006/07/09" so when response writen u get a nice 2006/07/09 as entered...

2. When looking at the DB at the dates entered there it is in the above format, but when response writen it comes out as 7/9/2006 which is fine, cause i then in turn use Locale to convert back to 2006/07/09, but here is my problem, when trying to call it from the DB nothing happens.

So I then used the idea of converting the entered text to US 2006/07/09 ---> 7/9/2006 and then search for the date I want but nothing either...

Here is some code
<table>
  <tr>
    <td>Type the date u looking for:&nbsp;<input type="text" name="searchdate2" /></<br />
    <td><input type="submit" value="Look for" /></td>
  </tr>
</table>
<%
    'Get the Date Entered'
        Dim datSearchDate
            datSearchDate = Request.Form("searchdate2")

        Response.Write ("Date that was entered (typed): ") & ("<font color='red'>") & datsearchdate & ("</font><br>")
    
    'Convert the date to US standard'
        Dim varDate
        Dim varLocale
        Dim dattoUS
        
            varLocale = SetLocale(1033)
            varDate = datSearchDate
            dattoUS = FormatDateTime(varDate, 2)
            
        Response.Write ("Date as converted back to US") & " " & ("<font color='red'>") & dattoUS & ("</font><br>")
        
    'Search DB for date'
    Dim adoCon
    Dim objRS
    Dim strSQL
    
    Set adoCon = Server.CreateObject("ADODB.Connection")
    adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("sms.mdb")
    Set objRS = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM clients"
    objRS.Open strSQL, adoCon
        
        Do While Not objRS.EOF
         If objRS("datetosend") = dattoUS Then
            Response.Write objRS("datetosend") & " " & objRS("phonenumber")
        Else
            Response.Write ("Not Found")
        End If

        objRS.MoveNext
        Loop

%>


It just gives me a LOOOOOOOONG list of whats in the datebase, not the exact row I'm looking for.
Can anyone help in this regard please.??
Last edited by GavinC : Jul 24th, 2006 at 10:48 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Help with dates please

  #2  
Jul 24th, 2006
can you post your output?
Reply With Quote  
Join Date: Jul 2006
Posts: 9
Reputation: GavinC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
GavinC GavinC is offline Offline
Newbie Poster

Re: Help with dates please

  #3  
Jul 26th, 2006
Sorry I haven't gotten back to you...

I am just quickly changing some stuff to see if I can't make it simpler for myself... it seems that I have made it more complicated than what its supposed to be...

Will post it soon, if I get the same problem...
Reply With Quote  
Join Date: Jul 2006
Posts: 9
Reputation: GavinC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
GavinC GavinC is offline Offline
Newbie Poster

Help Re: Help with dates please

  #4  
Jul 26th, 2006
Originally Posted by campkev
can you post your output?

Hey there, o.k. I have redone the code work and now what I get is just a list of dates... basically everything out of the database.... not the specific one I am looking for.

i.e:
7-9-2006 This is the Info from the previous page
Date as converted back to US 7/9/2006

RETREIVING INFO FROM THE DATABASE ACCORDING TO DATE ENTERED
Take the date from the previous page and converted 7/9/2006
and match it up in DB.
7/9/2006
8/23/2007
7/8/2006
9/23/2006
10/7/2006
8/15/2006
9/4/2007
11/6/2007
1/19/2008
11/7/2007
4/6/2007
6/5/2007
11/28/2007
12/2/2007
10/30/2007
7/5/2007

and the list Goes on, here is the code for it....

<%
    Dim strSearchDate
        strSearchDate = Request.Form("searchdate")
       
        
    Response.Write strSearchDate & ("&nbsp;This is the Info from the previous page<BR>")
    
    'Convert the date to US standard for strSearchDate'
        Dim varDate
        Dim varLocale
        Dim dattoUS
        
            varLocale = SetLocale(1033)
            varDate = strSearchDate
            dattoUS = FormatDateTime(varDate, 2)
            
        Response.Write ("Date as converted back to US") & " " & ("<font color='red'>") & dattoUS & ("</font><br><br>")
%>
<!-- RETREIVING INFO FROM THE DATABASE ACCORDING TO DATE ENTERED -->
<%
    Response.Write ("<font color='red'><strong><u>RETREIVING INFO FROM THE DATABASE ACCORDING TO DATE ENTERED</u></strong></font><br>")
    Response.Write ("Take the date from the previous page and converted") & " " & ("<font color='red'>") & dattoUS & ("</font><br>")
    Response.Write ("and match it up in DB.<br>")
    
    'Connect to the DB'
    Dim adoCon
    Dim objRS
    Dim strSQL
    
    Set adoCon = Server.CreateObject("ADODB.Connection")
    adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../sms.mdb")
    Set objRS = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM clients"
    objRS.Open strSQL, adoCon
        
    Do while not objRS.EOF
        Dim dattodb
            dattodb = dattoUS
                'Response.Write dattodb & ("<BR>")
                
            if objRS("datetosend") = dattodb Then
                Response.Write ("Not Found")                
            Else
                Response.Write objRS("datetosend") & ("<BR>")
            End if
    objRS.MoveNext
    loop
%>

Dunno what I am doing wrong here.... Any ideas???
Reply With Quote  
Join Date: Jul 2006
Posts: 9
Reputation: GavinC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
GavinC GavinC is offline Offline
Newbie Poster

Help Re: Help with dates please

  #5  
Aug 3rd, 2006
Hi there, I am still stuck on a dates issue, I am trying to get this going but just cant seem to get it going....

Restructered the ACCESS DB with 4 fields.
ID (autonumber), Fullname (text), phonenumber (text), datetosend (DateTime).

The Date field is set to either "shortdate" or "general date" but dont think the problem lies here....

So with this I have a Datepicker that enables you to choose a date and you hit the submit button and it goes though to the next page... all working good...

I then have this code....

<%
    Dim strSearchDate
        strSearchDate = Request.Form("searchdate")
                
    Response.Write strSearchDate & ("&nbsp;This is the Info from the previous page<BR>")
    
    'Convert the date to US standard for strSearchDate'
        Dim varDate
        Dim varLocale
        Dim dattoUS
        
            varLocale = SetLocale(1033)
            varDate = strSearchDate
            dattoUS = FormatDateTime(varDate, 2)
            
        Response.Write ("Date as converted back to US") & " " & ("<font color='red'>") & dattoUS & ("</font><br><br>")
%>
<!-- RETREIVING INFO FROM THE DATABASE ACCORDING TO DATE ENTERED -->
<%
    Response.Write ("<font color='red'><strong><u>RETREIVING INFO FROM THE DATABASE ACCORDING TO DATE ENTERED</u></strong></font><br>")
    Response.Write ("Take the date from the previous page and convert to") & " " & ("<font color='red'>") & dattoUS & ("</font><br>")
    Response.Write ("Retreive all Dates in DB.<br>")
    
    'Connect to the DB'
    Dim adoCon
    Dim objRS
    Dim strSQL
    
    Set adoCon = Server.CreateObject("ADODB.Connection")
    adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../sms.mdb")
    Set objRS = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM clients WHERE someDateField = # 2006/09/07 #"
    objRS.Open strSQL, adoCon
        
    
%>

and this is the error I am receiving


HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services


Technical Information (for support personnel)
  • Error Type:
    Microsoft JET Database Engine (0x80040E10)
    No value given for one or more required parameters.
    /activesms/date check/dateretreived.asp, line 34
  • Browser Type:
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
  • Page:
    POST 19 bytes to /activesms/date check/dateretreived.asp
  • POST Data:
    searchdate=7-9-2006
  • Time:
    Thursday, August 03, 2006, 9:23:51 AM
  • More information:

Can anyone give some feedback in regards to this, even if its a "I dont know" comment... :cheesy:
Last edited by GavinC : Aug 3rd, 2006 at 3:41 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 11:13 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC