Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Hide after 30 days

Author  Topic 

trudge
Starting Member

2 Posts

Posted - 2009-06-04 : 20:54:34
I have a database that pulls info for job postings.
I want to pull the job postings that are not older than 30 days since being entered into the database (created).
Currently the list will pull all jobs posted in the database that are not older than the Closing Date (cddate).
How can I tell it to not pull the ones that are older than 30 days?

<%
Dim rs,x,ldate
ldate = date
rs = make_rs(connstr, "Select * from jobs where (cddate > '"&ldate&"') and authorized = 'Yes' order by ID Desc")
if rs(0)("no_matches") = "" then
%>
<table cellpadding="2" cellspacing="1" width=100% bgcolor="#b7b7b7">
<tr bgcolor="#D3D5EA">
<td valign="bottom"><b class="bleu">Job #</b></td>
<td valign="bottom"><b class="bleu">Job Title</b></td>
<td valign="bottom"><b class="bleu">Salary Range</b></td>
<td valign="bottom"><b class="bleu">Company</b></td>
<td valign="bottom"><b class="bleu">Location</b></td>
</tr>
<%for x = 0 to ubound(rs)-1%>
<tr onMouseOver="this.style.backgroundColor='#E8FFFE';this.style.cursor='hand'"
onMouseOut="this.style.backgroundColor='#FFFFFF'" bgcolor="#FFFFFF" onClick="window.location='jobdetail.asp?ID=<%=rs(x)("ID")%>';">
<td valign=top><a href="jobdetail.asp?ID=<%=rs(x)("ID")%>"><%=rs(x)("ID")%></a></td>
<td valign=top><a href="jobdetail.asp?ID=<%=rs(x)("ID")%>"><%=rs(x)("jobtitle")%></a></td>
<td valign=top><a href="jobdetail.asp?ID=<%=rs(x)("ID")%>"><%=rs(x)("salrange")%></a></td>
<td valign=top><a href="jobdetail.asp?ID=<%=rs(x)("ID")%>"><%=rs(x)("coname")%></a></td>
<td valign=top><a href="jobdetail.asp?ID=<%=rs(x)("ID")%>"><%=rs(x)("city")&"<br>"&rs(x)("prov")%></a></td>
</tr>
<%
next
response.write "</table>"
else
%>
<b>There are currently no open job postings.</b>
</table>
<%end if%>

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-04 : 21:01:47
where created >= dateadd(day, datediff(day, 0, getdate()), -30)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

trudge
Starting Member

2 Posts

Posted - 2009-06-04 : 21:14:00
Wow that is fast. Thank you so much.
Go to Top of Page
   

- Advertisement -