Forums

This topic is locked

Show image IF record less than "x" days old..

Posted 15 Nov 2003 02:13:50
1
has voted
15 Nov 2003 02:13:50 Dave Thomas posted:
Lo all

im trying to show a "new" image next to a record that is less than 7 days old in the database with no success. This is in a repeat region.


<pre id=code><font face=courier size=2 id=code>&lt;%
DIM strDate, strNew

strDate = rsArticles.Fields.Item("DateAdded".value
strNew = response.write ("&lt;img src='new.gif'&gt;&lt;/img&gt;"

IF DateDiff("d", Date(), strDate &lt;= 7 THEN
response.write strNew
ELSE
END IF
%&gt;
</font id=code></pre id=code>

using dwmx 2004, asp/vbscript
TIA

Regards,
Dave

UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro

Replies

Replied 15 Nov 2003 02:56:07
15 Nov 2003 02:56:07 Nozomi Kugita replied:
The DateDiff function [DateDiff(interval, date1, date2)] returns a negative number if date1 refers to a later point in time than date2.

So the evaluation should be "if the date difference is greater than -7", I think...

HTH,
- Noz
Replied 15 Nov 2003 09:09:36
15 Nov 2003 09:09:36 Dave Clarke replied:
hi dave

dunno if this would work but it might be worth a shot.

&lt;%
DIM strDate, strNew
strDate = rsArticles.Fields.Item("DateAdded".value
strNew = response.write ("&lt;img src='new.gif'&gt;&lt;/img&gt;"
<b>IF strDate &gt;= (Date()-7) THEN</b>
response.write strNew
ELSE
END IF
%&gt;


Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Edited by - Davecl on 15 Nov 2003 09:10:25
Replied 15 Nov 2003 12:40:48
15 Nov 2003 12:40:48 Dave Thomas replied:
no m8,
still shows an image for every record <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>

time for some serious searching me thinks,
cheers Dave, Noz


Regards,
Dave

UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro
Replied 15 Nov 2003 21:47:57
15 Nov 2003 21:47:57 Phil Shevlin replied:
Your original concept will work. You had some errors in the script.

<pre id=code><font face=courier size=2 id=code>
&lt;%
DIM strDate, strNew
strDate = "11/08/2003"
strNew = "NEW"
IF (DateDiff("d", Date(), strDate) &gt;= -7) THEN
response.write strNew
END IF
%&gt;
</font id=code></pre id=code>

I tested it

Edited by - wdglide on 15 Nov 2003 21:53:30
Replied 15 Nov 2003 21:55:11
15 Nov 2003 21:55:11 Phil Shevlin replied:
strNew = response.write ("&lt;img src='new.gif'&gt;&lt;/img&gt;"

was writing the image before the if statement. also there were logic and parse errors
Replied 15 Nov 2003 23:52:41
15 Nov 2003 23:52:41 Dave Thomas replied:
woohoo thx a lot.

im not the best handcoder, but im prepared to give it a logical shot rather than just be a lame arse build me a script type of guy <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Appreciated

see it in action &gt; www.nova-cs.co.uk
Regards,
Dave

UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro

Edited by - UltraDav on 16 Nov 2003 00:07:54
Replied 16 Nov 2003 06:41:22
16 Nov 2003 06:41:22 Dave Clarke replied:
duh! us eh?
we should have spooted that <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>

glad you got it working mate, site looking good.

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 16 Nov 2003 08:19:56
16 Nov 2003 08:19:56 Nozomi Kugita replied:
Ah!
I looked at the IF statement too closely to notice that order <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

- Noz

Reply to this topic