473,605 Members | 2,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to extract data between two dates

1 New Member
Hi All,
I am unable to get the excel open when user select two dates from my code. Previously i was successfully extracting values by selecting year and month values from the webpage. Could you help me out in writing the Access 2003 SQL query to resolve my issue. Looking forward to your help and support:) I am giving the snapshot of my code:

Expand|Select|Wrap|Line Numbers
  1. <%@Language=VBScript%>
  2.  
  3. <%
  4.     Dim TmplXls
  5.     Dim DestXls
  6.     Dim DB
  7.     Dim DBConn
  8.     Dim DestXlsConn
  9.     Dim FSO
  10.     Dim XlsRS
  11.     Dim DBRS
  12.     Dim sqlText
  13.     Dim strMnth
  14.     Dim strYear
  15.     Dim strlte10Pcnt
  16.     Dim cnt1
  17.     Dim cnt2
  18.     Dim cnt3
  19.  
  20.  
  21.  
  22.     If Request.Form("Fst").Count = 0 Then
  23.     strStartDate = "(Fst = Format([date],'ddmmyyyy'))"
  24.     Else
  25.         For cnt2 = 1 to Request.Form("Fst").Count
  26.             If cnt2 = 1 Then
  27.                 strStartDate = "(Fst = " & Request.Form("Fst")(cnt2)
  28.             Else
  29.                 strStartDate = strStartDate & " OR Fst = " & Request.Form("Fst")(cnt2)
  30.             End If
  31.     Next
  32.         strStartDate = strStartDate & ")"
  33.     End If
  34.  
  35.     If Request.Form("Lst").Count = 0 Then
  36.         strLastDate = "(Lst = Format([date],'ddmmyyyy'))"
  37.     Else
  38.         For cnt3 = 1 To Request.Form("Lst").Count
  39.         If cnt3 = 1 Then
  40.                 strLastDate = "( Lst = " & Request.Form("Lst")(cnt3)
  41.             Else
  42.                 strLastDate = strLastDate & " OR Lst = " & Request.Form("Lst")(cnt3)
  43.             End If
  44.         Next
  45.         strLastDate = strLastDate & ")"
  46.     End If
  47.  
  48.  
  49.  
  50.  
  51.     'Response.Write strYear
  52.  
  53.     TmplXls = Server.MapPath(".") & "\Memory_Use_Sample.xls"
  54.     DestXls = Server.MapPath(".") & "\Memory_Use.xls"
  55.     DB = Server.MapPath(".") & "\Server_Monitoring.mdb"
  56.  
  57.     Set FSO = Server.CreateObject("Scripting.FileSystemObject")
  58.     FSO.GetFile(TmplXls).Copy DestXls
  59.  
  60.  
  61.     Set FSO = Nothing
  62.  
  63.     Set DestXlsConn = Server.CreateObject("ADODB.Connection")
  64.     DestXlsConn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & DestXls & "; " & "Extended Properties=""Excel 8.0;HDR=NO;"""
  65.  
  66.     Set XlsRS = Server.CreateObject("ADODB.Recordset")
  67.     'XlsRS.Open "Select * from Report_Range", DestXlsConn, 1, 3
  68.     XlsRS.Open "Select * from Memory_Use", DestXlsConn, 1, 3
  69.  
  70.     Set DBConn = Server.CreateObject("ADODB.Connection")
  71.     Set DBConn = Server.CreateObject("ADODB.Connection")
  72.     DBConn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & DB
  73.  
  74.     Set DBRS = Server.CreateObject("ADODB.Recordset")
  75.     sqlText = "Select date, Time_Hour, ServerName, MemoryUse from Q1 where date between" & strStartDate
  76.  
  77.     'strSQL = "SELECT * " & _ 
  78.         ' "FROM [RECORDS] " & _ 
  79.          '"WHERE (CDate(Date_Pur) Between #" & _ 
  80.         ' Format(Date_From,"m/d/yyyy") & "# And #" & _ 
  81.         ' Format(Date_To,"m/d/yyyy") & "#)" 
  82.  
  83.    'Response.Write strText
  84.   ' Response.End
  85.         If Request.Form("Lst").Count > 0 Then
  86.             sqlText = sqlText & " AND "& strLastDate 
  87.         End If
  88.  
  89.     'Response.Write sqlText
  90.     'Response.End
  91.  
  92.     DBRS.Open sqlText, DBConn, 1
  93.      'Response.Write sqlText    
  94.      'Response.End    
  95.  
  96.            If DBRS.Recordcount > 0 Then
  97.         DBRS.MoveFirst
  98.  
  99.         Dim x, y
  100.         x = 1
  101.         Do While Not (DBRS.EOF)
  102.             XlsRS.AddNew
  103.             XlsRS.Fields(0).Value = x
  104.  
  105.             For y = 1 To 4
  106.                 XlsRS.Fields(y).Value = DBRS.Fields(y-1).Value
  107.             Next
  108.             XlsRS.Update
  109.             DBRS.MoveNext
  110.             x = x + 1
  111.         Loop
  112.  
  113.         Response.Write "<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=Memory_Use.xls"">"
  114.         'Response.Write "Matching records found"
  115.  
  116.     Else
  117.         Response.Write "No matching records found"
  118.     End If    
  119.  
  120.  
  121.     DBRS.Close
  122.     Set DBRS = Nothing
  123.  
  124.     DBConn.Close
  125.     Set DBConn = Nothing
  126.  
  127.     DestXlsConn.Close
  128.     Set DestXlsConn = Nothing
  129.  
  130.     'Response.Write "<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=Memory_Use.xls"">"
  131.     'XlsRS.Close
  132.  
  133.     'Set XlsRS = Nothing
  134. %>
Nov 4 '08 #1
1 4048
jhardman
3,406 Recognized Expert Specialist
Hi All,
I am unable to get the excel open when user select two dates from my code. Previously i was successfully extracting values by selecting year and month values from the webpage. Could you help me out in writing the Access 2003 SQL query to resolve my issue. Looking forward to your help and support:) I am giving the snapshot of my code:
So what part doesn't work? Are you getting a syntax error when you query the db? Try doing a response.write of the query from the working version and from the current broken version, I bet you will see an obvious difference. If you don't please post both versions of the query (like it looks when finished).

Jared
Nov 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2318
by: lawrence | last post by:
I'm probably missing something obvious, but I'm unable to write a file with this function. I've used my FTP software to set permissions to 777 on all the files in question. I've tried r, r+, w, and w+ as possible ways of opening the files. The first fopen is trying to create a file where none exists. It fails (thought I've set dir permissions to 777 as well). How can I create a file? There error messages print back the full input, so...
17
3008
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). I have a dataset as follows (1 week to keep it short): Employee 1 - Date 1 Employee 1 - Date 2
5
102412
by: rs | last post by:
I have a table with a timestamp field which contains the date and time. ie. 9/13/2004 9:10:00 AM. I would like to split this field into 2 fields, one with just the DATE portion ie 9/13/2004 and the other with just the TIME portion. ie 9:10:00 AM. I can make the table view display what I want by placing the same data in 3 fields and setting the display property to 'General Date',' Medium Time' and 'Short Date' but the underlying data...
10
3027
by: Elric02 | last post by:
I'm currently trying to get access to the Python source code, however whenever I try to extract the files using the latest version of WinZip (version 10) I get the following error "error reading header after processing 0 entries" I was under the impression that I could (from reading the various posts on this group) that I could simply extract the tar ball, using WinZip. If this is not the case does anybody know how I can actually get...
3
5703
by: maylee21 | last post by:
hi, anyone can help me figure out how to read data from a text file like this: 10980012907200228082002 and extract the data according to this kind of format: Record type 1 TY-RECORD PIC (1). ID-PARTICIPANT PIC (6).
2
1751
by: kashigal | last post by:
<? session_start(); require("db.php"); mysql_connect(MACHINE, USER, ''); mysql_select_db(DBNAME); $username = $_SESSION; $pwd =$_SESSION;
5
2404
by: pinpe | last post by:
Hi, I have problem of filtering a log file from my perl script. This is the file content of the file pinpe.csv: 2009-06-16 2009-01-29 2009-06-02 2008-03-05
1
1607
by: GS | last post by:
I need to extract sections out of a long string of about 5 to 10 KB, change any date format of dd Mmm yyyy to yyyy-mm-dd, then further from each section extract columns of tables. what is the best approach in using regex for this? I can see match and replace the dates, extract section with regex, and then for each section extract again with the right regex the tables....
1
3064
by: veer | last post by:
Hi i am making a program in which i want to extract data from html file . Actually there are two dates on html file i want to extract these dates but the main probleum is that these dates are different on each file. A word "AKTIVA" is always comes before these dates. i made this by seaching the activa word but after this i am not getting any idea how these dates can be accessed. i use one another method by transfering the whole data of...
0
8004
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7934
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8288
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.