Jump to content
Sign in to follow this  
mboehler3

Logic using Date() function

Recommended Posts

Hi, I have a non-dynamic site that I can only update once a month. Some pages have date-sensitive copy, such as "Sign up for our July 9 newsletter." As a result, I have to use logic so copy like that will not show up on July 10. I've been using logic such as this:

<% IF Date() <= "7/09/2010" THEN %>Sign up for our July 9 newsletter	<% ELSE %>	<%END IF %>

And it works fine. The problem is when I get to double digit months like October, where I use logic like this:

<% IF Date() <= "10/09/2010" THEN %>Sign up for our October 9 newsletter	<% ELSE %>	<%END IF %>

For some reason, no code appears when I use this logic. Is there a problem with double digit months that causes this logic to break? Any help is appreciated, thanks.

Share this post


Link to post
Share on other sites

Date() returns a date, "7/09/2010" is a string.You need to find an ASP function that accepts a string and returns a date for comparison. Check DateDiff or DateCompare.

Share this post


Link to post
Share on other sites

Thanks for the link.When I try using this code:

<% IF DateDiff ("d", Date(), #01/07/2010#) > 0 THEN %>

it doesn't work properly (I substituted 01/07/2010 with 06/21/2010). is there something i'm missing?

Date() returns a date, "7/09/2010" is a string.You need to find an ASP function that accepts a string and returns a date for comparison. Check DateDiff or DateCompare.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...