473,574 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need possible array help

2 New Member
I have a SQL table called "EXAMPLE" with 2 columns; personId and reportDate. personId consists of a 36 character GUID. reportDate has a date such as 1/1/2005, 2/1/2005,3/1/2005, etc. The date is always the first of the month. Sometimes they are skipping months, ie; 6/1/2006,7/1/2006,11/1/2006,12/1/2006, etc.

Now to my long winded question:

I have an ASP page that displays the selected month and associated personId data based on passing the personId and reportDate in the querystring. If I am on a page looking at personId '123' and reportDate '2/1/2006', for example, I want to place 2 hyperlinks on the page for the reportDate before and after for that personId. So, using my example, the page should show a link to 1/1/2006 and 3/1/2006. The problem is, if 3/1/2006 is not in the DB, it should go to the next available date in the DB. Also, if 2/1/2006 is the last date, or similarly 1/1/2006 is the first, their should not be a link to the dates before and/or after due to this.

Any ideas?
Mar 21 '07 #1
2 1153
3,406 Recognized Expert Specialist
The problem is, if 3/1/2006 is not in the DB, it should go to the next available date in the DB.
this one is easy if answered by itself. I assume you are linking with something like:[html]<a href="samePage. asp?date=3/1/2006">next month</a>[/html] right? just open the db with this query:
Expand|Select|Wrap|Line Numbers
  1. query = "SELECT * FROM EXAMPLE WHERE reportDate >= " & request("date") & " ORDER BY reportDate"
then just use the first record. The big problem is you can't tell with this method if there is anything before the record you pulled up, so it won't work to try this and solve the second question.

Also, if 2/1/2006 is the last date, or similarly 1/1/2006 is the first, their should not be a link to the dates before and/or after due to this.

Any ideas?
This one is tougher. To solve both together you need to do something like this:
Expand|Select|Wrap|Line Numbers
  1. query = "SELECT * FROM EXAMPLE ORDER BY reportDate"
  2. objRS.open query, objConn, adOpenDynamic
  3. prevMonth = objRS("reportMonth")
  4. if prevMonth = request("date") then 
  5.    'date requested is first in db, so handle accordingly
  6.    'you might not actually need anything here at all
  7. else
  8.    objRS.moveNext
  9.    do until dateDiff("d", objRS("reportMonth"), request("date")) <=0
  10.       prevMonth = objRS("reportDate")
  11.       objRS.moveNext
  12.    loop
  13.    'the exact date of the previous
  14.    'month is saved as "prevMonth"
  15.    'I would create the link to the previous month here
  16. end if
  17. 'you are currently on the record requested, the link to the previous
  18. 'month was create if needed. I would try "objRS.moveNext" to find
  19. 'the exact date of the next record so that I can write the link to
  20. 'the exact date needed next, but that's just me
Let me know if this helps.

Mar 22 '07 #2
2 New Member

Thank you very much. You solved the problem for me. This was a mental block that I could not figure out.
Mar 22 '07 #3

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

Similar topics

by: Mekon | last post by:
I have never written a line of script in my life but I need some help with it now. I have this auto generated code which I want to modify if possible The script generates a strip of thumbnails, and works quite well execpt that on dial up it is unbearably slow. The Thumbnails themselves are only 10kb but the total of them is a lot larger....
by: Tommy Lang | last post by:
I am working on this project and I need some help/pointers/comments to get me started, I am stuck. The program will be used to store information in an array while it is running. I need to store objects of my classes Person(superclass), Student(inherit Person), Teacher(inherit Person) in that array. The name will be the unique key. These...
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it...
by: semooo | last post by:
hi Im waseem I need an immediate help as soon as possible, I have three simple question with coding problems in data structure in c++ thess are : 1)suppose that you are finanicier and purchase 100 shares of stock in company X , in each of january , april , and september and sell 100 shares in each of june and november the price per share...
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
by: nephish | last post by:
Hello there, i am getting to need to make my web stuff more OO. i have a project at work that we are porting to the internet, and i started learning php to do so. the project is now mamoth is size, and code is reused and pasted all over it. I plan to do a good re-write using better, and cleaner code. So i want to incorporate some classes....
by: James | last post by:
Is this possible? I want to pass an array into a function that contains txtBox.Text properties... I was thinking something like this, but I know it won't work Dim vendorFields(9) As String vendorFields(0) = "txtVendorName.Text" vendorFields(1) = "txtVendorStreetAddress.Text" vendorFields(2) = "txtVendorCity.Text" ....
by: Ouwet5775 | last post by:
Hey guys i have been working on a C++ program as a revision for an upcoming final exam. One of the main point is to know how to create a function that would invert the elements in your array. That one has given me alot of trouble. A tip or a hint would be greatly appriciate it :D ie: A={1,2,3} -------> A'={3,2,1} Now i have tried using...
by: ChillyRoll | last post by:
Hello guys, I am looking for a parser in PHP that can return all the attributes of XML entities. I know how to read the XML Entities, but I have got a problem with reading attributes. So I will appreciate if you could give a parser that can return all the Entities and Attributes of respective entities as an array. For e.g.: <?xml...
by: falconsx23 | last post by:
I am making a game called Set, it is a card game: here is a brief description of the rules: The game of Set is played with 81 cards, each of which has 4 properties (number, pattern, color and shape). The number of objects is 1, 2, or 3. The 3 possible patterns are solid, striped, and open. The 3 possible colors are red, green, and purple. The...
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...
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...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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...
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...
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...
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...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.