codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Display on a date and remove on a date using I think SQL?  trevorsaint at 14:16 on Tuesday, February 17, 2004
 

Hi all

This is my first post so go easy :)

I would like two extra fields in my database, one for

startDate and one for endDate.

The outcome I am trying to achieve, is when an admin user adds a start date for an article he or she has produced, they can then choose to display this on a paricular date, and for it to be taken off display or availability using the endDate field that was inputted.

I am guessing some form of SQL statement would be the route to go in doing this, and could really use any help in achiving this.

Thanks

Trevor Saint.

  Re: Display on a date and remove on a date using I think SQL?  Troy Wolf at 00:15 on Monday, February 23, 2004
 

Are you asking how to modify a database table to add 2 columns? What database are you using? SQL Server, Access, MySQL, etc.?

I'm just not clear on what part of the solution you need assistance with. Let us know.
Troy Wolf: site expert
Shiny Solutions


  Re: Display on a date and remove on a date using I think SQL?  trevorsaint at 00:25 on Monday, February 23, 2004
 

Hi Tony, cheers for the reply.

I am using an access database, alongside Dreamweaver. I have developed a small content management system whereby the user can login, add, edit and delete a news article.

My boss, has now asked if it is possible to add two extra column to allow the admin user to specify a start date and an end date for a selected news article.

For example, I am going to add a news article using the CMS, I want the article to be displayed on the 01/03/2004, and I want the news article to be taken off display on 02/04/2004. This does not really need deleting from the database, but rather just not displayed.

I do have a feeling it is done via an SQL statement, I understand this may not be an easy task, but it would be good to have an idea in what to be facing.

I am not excellent with ASP, so I am still in the struggle stages of it, but with the right guidance can do well.

I hope this is a little more clear for my request, if you still not sure what I am after, then please let me know.

Thanks again, and I look forward to hearing from you again.

Kind regards

Trevor Saint

<Added>

Hi Troy, cheers for the reply.

I am using an access database, alongside Dreamweaver. I have developed a small content management system whereby the user can login, add, edit and delete a news article.

My boss, has now asked if it is possible to add two extra column to allow the admin user to specify a start date and an end date for a selected news article.

For example, I am going to add a news article using the CMS, I want the article to be displayed on the 01/03/2004, and I want the news article to be taken off display on 02/04/2004. This does not really need deleting from the database, but rather just not displayed.

I do have a feeling it is done via an SQL statement, I understand this may not be an easy task, but it would be good to have an idea in what to be facing.

I am not excellent with ASP, so I am still in the struggle stages of it, but with the right guidance can do well.

I hope this is a little more clear for my request, if you still not sure what I am after, then please let me know.

Thanks again, and I look forward to hearing from you again.

Kind regards

Trevor Saint

  Re: Display on a date and remove on a date using I think SQL?  Troy Wolf at 01:20 on Monday, February 23, 2004
 

Your welcome. I'm clear on what you want to do. I'm not clear on what exactly you are asking for. I assume you created the Access database you are using and the current code, so I have to assume you know how to simply open your database in Access and add 2 more columns. But if you created the current code that is capable of submitting and pulling articles from the database, I'd have to assume you know how to modify your query to include the startDate and endDate in your SQL statement.

With these assumptions, I don't know what you don't know. Here is some code that may help you. I surrounded the dates with pound signs (#) because if I'm correct, this is how you do it in Access? In standard SQL, you use single quotes.


' ASP Date function returns current timestamp.
dtToday = Date()

' Build your sql statement.
sql = "select articleID, article from articles where startDate <= #" & dtToday & "# and endDate >= #" & dtToday"#"



<Added>

I made a mistake in the sql statement. I left out one (&).

sql = "select articleID, article from articles where startDate <= #" & dtToday & "# and endDate >= #" & dtToday & "#"
Troy Wolf: site expert
Shiny Solutions


  Re: Display on a date and remove on a date using I think SQL?  trevorsaint at 02:53 on Monday, February 23, 2004
 

Hi Wolf, well in terms of the database etc I am intermediate, but with ASP i must be honest and say I could not write code from scratch, I can figure out areas, and make modifications etc, but still behind. I used Dreamweaver to do most of the hard work for me. But DW can have its limitations, which I was sure this type of thing would have to be hand coded.

Am I right in thinking that if I modify the SQL statement in the code with what you have, providing my two columns are labelled startdate and enddate, this will function. So in a result of a user typing a start date and an end date this should work?

I will have to try it. The only concern is this is an added feature of the system, I am assuming this may interfere with the standard date input.

What I am after is where the user has the option of inputting a start date and end date. So messing with the original SQL Query may effect this. I am not sure.

If it is ok, I will prepare the system, with the extra fields. Then could you have a look at the code? This would be good, but if it is just a case of modifying the SQL, then there will be no need. Anyway its getting late over here :) much get some sleep before work :)

Hear from you soon Wolf.

  Re: Display on a date and remove on a date using I think SQL?  Troy Wolf at 03:51 on Monday, February 23, 2004
 

I can't guarantee my time to look at your code, but let's see how far we can get! So are you working with a pre-built app, and now you want to modify it? Or did you write the app to start with using Dream Weaver?

Yes, the date format will be something you have to consider when allowing users to enter dates. For date entry, you are better off using one of the many free javascript calendars and force your users to use the calendar tool to pick the dates. (It is actually a help to most users--except true data entry people.)

So you have an HTML FORM now that the user enters their article data? Right? You'll add two fields, date to start the article, and a date the article expires. These will be text input fields, but tied to a javascript calendar function so the user does not directly modify the date, but rather uses a popup calendar to pick the date. (This is just one way to do this of course.) Then when the form is submitted, you build your SQL statement in your ASP using the form data that was submitted.

Then when your app selects articles to display, it only pulls articles where today's date is within the article's date range. (The SQL statement I provided earlier is an example of how to form that statement.)

Experiment and search the web for code examples. You'll get there!
Troy Wolf: site expert
Shiny Solutions


  Re: Display on a date and remove on a date using I think SQL?  trevorsaint at 01:18 on Thursday, February 26, 2004
 

Cheers for that. I am sure I will figure it out sometime :). I have one more question for you wolf, if you dont mind.

I have my site holding page designed, and what I have done is used multi coloured elements, for example three images on the design are say green. I have labelled them colorarrow, colorblock, and finally colorlogo.

I have three different colour sets for these images. (Green, pink and orange).

So in total I have nine graphics, three for each, no change in dimensions etc.

My aim is to have a random image group set on the page. I am aiming to use the database of course, whereby I would have maybe some fields in there indicating something or another. Do you have any ideas on how I would achieve this? So basically it is random, but the three images are grouped as a random change otherwise it would be multi coloured if you get me. Hope this makes sense.

Any ideas, clues??

Cheers Wolf.


  Re: Display on a date and remove on a date using I think SQL?  Troy Wolf at 01:36 on Thursday, February 26, 2004
 

Sounds like a class assignment. You want me to do your homework?

I'm actually not sure what your goal is, but if I had 3 groups of 3 objects and I wanted any of the three objects to display randomely upon page load -- and the objects are as you describe: shapes of color. Then I would just put them all in the page inside hidden and absolute positioned DIV elements (using CSS). Then use javascript to randomely show one of the sets. No database necessary or even desired for that effect.
Troy Wolf: site expert
Shiny Solutions









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  Re: ASP.NET web controls
•  Re: JavaSript Problem In Mac Safari Browser
•  Re: DHTML div positionning Problem
•  Convert script to NS6 compatible - Please Help!
•  Print .doc file from the website using System.Diagnostics.Process
•  Re: Fullscreen code
•  Re: iframe targeting
•  Excel n ASP


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005