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 391,615 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,620 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: 1571 | Replies: 4
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  

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 12:21 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC