Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retreiving info from database according to date

Status
Not open for further replies.

GirlFriday1

Programmer
May 1, 2001
20
CA
Hello there!
I have a select box that allows the user to select records from the last 3, 6 or more than 6 months in the past. The trouble is is that I don't know how to do this. What I thought was maybe get the current date somehow, then subtract 90 from that for the 3 month selection, 180 for the 6 moths selection, etc. Any suggestions?
 
[tt]function Dates(){
var ,d,m,y //Define Variables.
x = new Date(); //Create Date object.
d = x.getDate(); //Get Day
m = (x.getMonth() + 1); //Get Month
y = x.getYear(); //Get Year.
alert('Date 1 : ' + d + "/" + m + "/" + y) //Show First Date
m = m - 6 //Deduct 6 Months
if (m < 0) //If the month is below zero
{m = m + 12;y=y-1} //scroll the clock back a year
alert('Date 1 : ' + d + &quot;/&quot; + m + &quot;/&quot; + y) //Show the Second Date
}[/tt]


Stick this in an HTML page with a href calling it, see if it will help you do what you need to do. Unsure how to help further.

Call me if you need me. DeltaFlyer ;-)

DeltaFlyer - The Only Programmer To Crash With Style.
 
Hello!
I have been playing around with this whole date thing for a while. That javascript code that Deltaflyer wrote is great, but how do you use just peices of the function? I want my system to automatically do the month calculation and only show the user the records that were made on or before that day. For example, a user enters the system today and when they look at the records, all they see are records from November 24 onwards. Next month, the records will be from December onwards, etc.
Any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top