Jump to content
  • 0

Search By Year


ISlp59lp

Question

I'm using the Search and Report Wizard.

 

I have a table(tbl_game) with one column containing a datetime field. (ex:  09/25/2009 18:00:00)

 

I have created the search form with a dropdown that allows user to select specific year (ex: 2009)

 

Now, how do I generate the search such that the report yields only those records with the selected year (ex: only 2009 games)?

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

MayMusic,

 

Thanks - I found the Precision field.

 

My next question is, can this be changed dynamically?

I actually have three drop down created (year, month, date).

 

One user might select just the year.  

Another user might select both the year and the month.

 

Is there a way to change the precision value of the field on the search page to match what the user has input?

Or, are there some default values that would work?  (for instance, if year is selected and month is not selected, yet the precision is set to Month and Year?)

Link to comment
Share on other sites

  • 0

In the search page for this field try to add criteria to the field and select OR as the operator between values. But you only have Date, Date and Time, Month and Year and Year options you cannot only choose Month !!! Give it a try and let me know though.

 

To add criteria to the field highlight the field name in Configure Search Field screen and then from the picker where you add HTML Block/Header/Footer you can also select Criteria

Link to comment
Share on other sites

  • 0

I did something a little different --  (but it doesn't seem to work...)

 

I created virtual fields for the year-month-date selections, then modified the value of the gamedatetime field and also the precision of the gamedatetime field.  (See below.)

 

But, the results select all dates, not restricted to year or month-year.

<script language ="JavaScript">
function setdate () {

  Stamp = new Date();

  year = document.getElementsByName('cbParamVirtual1')[0].value;
  month = document.getElementsByName('cbParamVirtual2')[0].value; 
  day = document.getElementsByName('cbParamVirtual3')[0].value; 

  if ((year !== "") && (month !== "") && (day !=="")){
    document.getElementsByName('VE_game_gamedatetime').precision = "Date";
    alert(document.getElementsByName('VE_game_gamedatetime').precision);
    fulldate = month + "/" + day + "/" + year;
    document.getElementsByName('VE_game_gamedatetime').value = fulldate;
    alert(document.getElementsByName('VE_game_gamedatetime').value);
  }
  else if ((year !== "") && (month !=="")){
    document.getElementsByName('VE_game_gamedatetime').precision = "Month and Year";
    alert(document.getElementsByName('VE_game_gamedatetime').precision);  
    fulldate = month +  "/" + year;
    document.getElementsByName('VE_game_gamedatetime').value = fulldate;
    alert(document.getElementsByName('VE_game_gamedatetime').value);
  }
  else {
    if (year == "")  year = Stamp.getFullYear();
    document.getElementsByName('VE_game_gamedatetime').precision = "Year";
    alert(document.getElementsByName('VE_game_gamedatetime').precision);
    fulldate = year;
    document.getElementsByName('VE_game_gamedatetime').value = fulldate;
    alert(document.getElementsByName('VE_game_gamedatetime').value);
  }
  
sportid = document.getElementsByName('cbParamVirtual4')[0].value;
schoolname = document.getElementsByName('cbParamVirtual5')[0].value;
oppschool = document.getElementsByName('cbParamVirtual6')[0].value;

document.getElementsByName('VE_game_sportid').value = sportid;
document.getElementsByName('VE_school_schoolname').value = schoolname;
document.getElementsByName('VE_Lookup_School_schoolname').value = oppschool;

alert(" sportid " + document.getElementsByName('VE_game_sportid').value + 
      "  school " + document.getElementsByName('VE_school_schoolname').value + 
      "  oppschool " + document.getElementsByName('VE_Lookup_School_schoolname').value);

}

/* onload=setdate; 

*/

document.getElementById("caspioform").onsubmit = setdate;

</script>

Link to comment
Share on other sites

  • 0

I've tried to simplify the search to see if I could get something going -  no go yet - still need help.

 

Using Search and Report Wizard:

  - Select Search Fields:  

          VE_game_sportid,

          VE_game_gamedatetime

  - Configure Search Fields:  

          DataPage Elements

                    Virtual1 - Dropdown (custom values:  2014,2013,2012,2011)

                    VE_game_sportid - Hidden, Default Value = 1

                    VE_game_gamedatetime - Hidden, precision = Date

           Footer is this code:

<script language ="JavaScript">
function setdate () {

  Stamp = new Date();
console.log("yippee");

  year = document.getElementsByName('cbParamVirtual1')[0].value;
console.log("input year:  %s",year);

    if (year == "")  year = Stamp.getFullYear();
console.log("set year: %s",year);
      var y = document.getElementsByName("VE_game_gamedatetime");
      y.precision = "Year";
console.log("y: '%s'", y.precision);

    fulldate = year;
    y.value = fulldate;
console.log("Date: '%s'",y.value);

}


document.getElementById("caspioform").onsubmit = setdate;

</script>

Still the results of this are for all years, not just the selected year.

 

What am I missing?

Link to comment
Share on other sites

  • 0

Hi

 

You can't change precision of the field via JS.

And as for your last post, looks like the same you can do without JS, just select Dropdown/Listbox form element for the VE_game_gamedatetime field and select precision 'year'. In the 'Source' dropdown select 'Custom values' and insert your custom values  "2014,2013 etc."

So in this case you don't need any JS and virtual fields.

 

As for the other cases, best solution is described in MayMusic's post

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   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...
×
×
  • Create New...