Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Determine a date base on #now()#

Guest
Mar 31, 2010 Mar 31, 2010

I have a small problem and I cant seem to find the solution too.

On my site, we have people filling out a very basic classified that appears in the weekly paper.

Our paper is produced every thursday, we also want the ads to appear on the site but they

must not display past the number of times they were selected to be inserted.

If someone fills the form out on Monday, March 30 (determined by #now()# and selects they want it to fun 3 times

I need to insert into my my classRunDate table the classified ID and the dates

EX

ClassifiedId      RunDate

546                   01/04/2010

546                   08/04/2010

546                   15/04/2010

Thanks in advance

Craig Wiseman

472
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2010 Mar 31, 2010

This goes to database design.  I'd consider having a min date and max date field in the appropriate table.  Then, when someone submits an ad, you can determine what n Thursdays from now will be and make that your max date.  Then you can display the ad if the current date is less than that max date.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 31, 2010 Mar 31, 2010

I agree you may want to re-think the structure. But to address the question about dates, you can use DayOfWeek() to identify the current "day" (ie 1-Sunday, ...., 7-Saturday) and some basic math to determine the number of days until the next Thursday (ie Day 5). Then use DateAdd("d", days, date) to calculate the new date(s). Check the date functions section of the documentation for more information.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 01, 2010 Apr 01, 2010
LATEST

A more straightforward design may be to have a table structure like this:

  • Classified_Ad_ID
  • Runs_Beginning_Date
  • Runs_Thru_Date
  • Number_of_weeks (included for your convenience)

When you insert a new ad, you are (for example) given the starting date and the number of weeks.  Based on this, you calculate the ending date.

Selection of the advertisements to be shown would select ads whose starting-date is on-or-before the current date, and the ending date is on-or-after the current date.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources