NetTalk Central

Author Topic: Passing Dates as report parameters  (Read 4795 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Passing Dates as report parameters
« on: June 09, 2010, 10:14:07 AM »
Nettalk 5 PR16
I am using a NetWeb Form to pass parameters to a report
Specifically if the fields I am passing dates
I create a variable called Fromdate set the field type as long and set the entry field as date.
In the report I create a field called Fromdate also as a long
In the Report Prime report options when run in web mode I set
FromDate = p_web.GetValue('FromDate')
If I select the date 1 may 2010  with the calendar date picker the value passed to the report is 1 If I select 30 June 2010 the value passed is 30.
If I change the entry field type to number and enter 75000 then 75000 is passed to the report.
Is there anything I should be doing to get the Clarion date value passed.

Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Passing Dates as report parameters
« Reply #1 on: June 09, 2010, 04:02:33 PM »
Check the value before it gets to your report - it may be getting cut off there rather than after it is being passed. Also try changing your variable from Long to Date type.

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Passing Dates as report parameters
« Reply #2 on: June 09, 2010, 09:34:01 PM »
Thanks for taking the time to reply Kevin.
I originally had the variable as date but changed it to long when I got this result as well. I'll test the value in the form.
Thanks.
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Passing Dates as report parameters
« Reply #3 on: June 09, 2010, 10:29:44 PM »
OK
In the WebForm embed Routines\Validate\FromDate I have placed this message
MESSAGE(p_web.GetValue('FromDate'))
(I know using message is bad but this is just a quickie)
the result on selecting 1 june 2010 is 1/06/2010, the value I receive in the report is 1.
It seems as though the Clarion date is not being created and the value passed is until the first none numeric character is found in the FromDate field..
I am going to try to parse this and set the value in the netwebform as date() after capture and see what this does.
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Passing Dates as report parameters
« Reply #4 on: June 10, 2010, 02:37:09 AM »
OK solved it like this
In my Routines.Validate.FromIndexDate embed
DateString = LEFT(CLIP(p_web.GetValue('FromIndexDate')))
DO DateConvert !becase I have more than 1 date range variables
p_web.SetValue('FromIndexDate',ReturnDate)

In ProcedureRoutines
 DateConvert ROUTINE ! date is in format d/mm/yyyy
 x# = INSTRING('/',DateString,1,1)
 dd = SUB(DateString,1,x#-1)
 DateString = SUB(DateString,x#+1,7)
 x# = INSTRING('/',DateString,1,1)
 mm = SUB(DateString,1,X#-1)
 DateString = SUB(DateString,x#+1,7)
 yyyy=LEFT(CLIP(DateString))
 ReturnDate = DATE(mm,dd,yyyy)
Exit
This sends the date as a Clarion Date and is received as a clarion date by the report and everything works. I know that doesn't happen in Nettalk 4 so I am assuming it has something to do with the jquery calendar object.
The situation appears to be that the calendar procedure has the value as a string so if the local variable that I am passing to the report is a long then only the first number of characters which are numeric will be received in the variable.
Am I correct in my assumption. If so is this a bug which will be fixed or shoud I assume that I have to do this in future?
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Passing Dates as report parameters
« Reply #5 on: June 16, 2010, 04:03:03 AM »
Hi Terry,

I was able to duplicate your effect in Example 13 (and I've left the new code in there for future releases if you want to check it out.)

At first I assumed there was a simple bug, but in fact it's slightly more complicated than that, specifically because this is a report.

In the example, there's a MailboxReportOptionsForm procedure, which gets some options for the report, and then a MailBoxesReportWithOptions report procedure.

In the report procedure there's a line of embed code, which copies the option into a local variable;

fromsize = p_web.GetValue('FromSize')

the local variable (fromsize) is then used in the report filter etc.

At first I added

fromdate = p_web.GetValue('FromDate')

but this fails with exactly the effect you describe. This is because the FromDate field comes to us from the browser formatted as '10/06/2010'.
To get it back into a long it needs to be Deformatted.
So the line in the report should read;

fromdate = deformat(p_web.GetValue('FromDate'),p_web.site.DatePicture)

or, I prefer

fromdate = p_web.dformat(p_web.GetValue('FromDate'),p_web.site.DatePicture)

Cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Passing Dates as report parameters
« Reply #6 on: June 16, 2010, 04:34:55 AM »
Thanks Bruce
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186