Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Find based on today's date

Featured Replies

I have a datebase of events that contain a "Start Date" and an "End Date" field. I want web users to see all events running for the current week, i.e., from today's date and for one week thereafter. At the moment I have to hard code individual dates. For instance, if I wanted to pull up events for the week beginning 8/1/2004, I'd have to put a link in like this:

<a href="FMPro?-db=DesignCalendarDB.fp5&-format=onthecalendar.html&-op=lte&Start%20Date=8/7/2004&-op=gte&End%20Date=8/1/2004&-find">

1. Is there any way to write this link so that it automatically uses today's date for this calculation (i.e., substitutes today's date for the "End Date" field in the above link

2. Can it calculate the value for the "Start Date" field above automatically, which will be today's date plus six days?

I know FMP needs to "process" this, which is why I have it as a link. Ideally, however, I'd like the current week's events to pull up automatically. Ideas? A meta refresh or something like that?

Lastly, basing a find on "currentdate" does not seem to work with FMP since currentdate returns a 2 digit year whereas FMP records dates with 4-digit years.

Thanks gang!

Rob

You can use Javascript to do all of that.

Good Luck.

Garry

  • Author

Right. The only problem with that is that I don't know javascript! I barely know CDML . . .

Anyone??

You could have this bit of Javascript in the <head>:

<script>

Today = new Date();

var sTodayDate = Today.getDate() + "/" + (Today.getMonth() + 1) + "/" + Today.getFullYear();

NextDate = new Date(Date.parse(Today) + (86400000 * 6));

var sNextDate = NextDate.getDate() + "/" + (NextDate.getMonth() + 1) + "/" + NextDate.getFullYear();

</script>

</head>


You can then use it like this:


<script>document.write("<a href='FMPro?-db=mydb.fp5&-format=mypage.html&-op=lte&Start%20Date=" + sNextDate + "&-op=gte&End%20Date=" + sTodayDate + "&-findall");</script>

The logic of the request may need to be changed however I hope this is helpful.

Good Luck.

Garry

  • Author

Thanks, Garry! Let me play around with it, and I'll let you know. In the meantime, where can I send the case of wine . . . ?

Love the wine smile.gif

Garry

  • Author

Garry -- I played with your syntax a little bit and I wound up turning it into a single script that I dropped into a markup item. It works fine, but as a link:

<script>

Today = new Date();

var sTodayDate = (Today.getMonth() + 1) + "/" + Today.getDate() + "/" + Today.getFullYear();

NextDate = new Date(Date.parse(Today) + (86400000 * 10));

var sNextDate = (NextDate.getMonth() + 1) + "/" + NextDate.getDate() + "/" + NextDate.getFullYear();

document.write('<a href="FMPro?-db=DesignCalendarDB.fp5&-format=newhome.html&-sortfield=Start%20Date&-sortorder=ascend&-op=lte&Start%20Date=' + sNextDate + '&-op=gte&End%20Date=' + sTodayDate + '&-op=neq&Event%20Type=Exhibit&-error=newhome.html&-find"><p class="style17"><span class="style16">Press Me!</span></p></a>');

</script>

While this script works as a link, I need it to run automatically on my home page. Is there a way to put this whole script in the head and use a meta refresh tag or something so that every time the home page loads the script runs this search and displays the results?

Best, RR

You can use an "onload=" in the <body> tag. This can call "newhome.html". For example:

<html><head><script>

Today = new Date();

var sTodayDate = (Today.getMonth() + 1) + "/" + Today.getDate() + "/" + Today.getFullYear();

NextDate = new Date(Date.parse(Today) + (86400000 * 10));

var sNextDate = (NextDate.getMonth() + 1) + "/" + NextDate.getDate() + "/" + NextDate.getFullYear();

</script></head>


Then:



<body onload="document.location='FMPro?-db=DesignCalendarDB.fp5&-format=newhome.html&-sortfield=Start%20Date&-sortorder=ascend&-op=lte&Start%20Date=' + sNextDate + '&-op=gte&End%20Date=' + sTodayDate + '&-op=neq&Event%20Type=Exhibit&-error=newhome.html&-find';">

Loading...</body></html>

Good Luck.

Garry

  • Author

Works PERFECTLY. Thanks so much, Garry.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.