Hi, probably there allready is support for such behavior ? Ihave a report to sum up daily orders on a web. It has a parametr with a date. Is there a way of providing default value = today ?
Thanks a lot.
Hi, probably there allready is support for such behavior ? Ihave a report to sum up daily orders on a web. It has a parametr with a date. Is there a way of providing default value = today ?
Thanks a lot.
Comments
Comment #1
metzlerd commentedNot yet, I typically handle this with a different tact, since dates are so tricky across databases. You have to then ask the question about which format the date is expected in. I typically handle this stuff in the data block for example in oracle:
I might be able to provide better code for you if you tell me both how your date data is stored, and which database you are trying to write for.
I'm really not quite sure how to implement this in a cross-database fashion, but I'll give it some thought.
Comment #2
mojzis commentedyou're right, i didnt realize ... so why not just allow php in the default value ? (I dont want to put it into SQL, because I would like the user to be able to select a different day ...)
Comment #3
metzlerd commentedNotice the COALESCE(:date_parm, trunc(sysdate)) in the sql. That means that if a user doesn't specify the date, it will use the current date, but if the user does specify the :date parameter, then its the date that they pass in.
Allowing PHP seems like a bit of a security risk to me.
Comment #4
mojzis commentedI am using mysql and date saved as a unix timestamp and unfortunately, this didnt work :
- the count returned zero. while this test returned data :
would it possible that the empty value is not passed as null ? arent you at some point adding '' around the param ?
thanks !
Comment #5
mojzis commentedI think my assertion above is proved true, when i insert nullif(:date,'') it works fine.
Comment #6
metzlerd commentedThis might be related to a driver specific problem. Are you extending the drupal repository or are you using a PDO mysql connection?
Comment #7
mojzis commentedextending drupal (6). thanks :)
Comment #8
metzlerd commentedYep found the problem. Should be fixed in the next beta.
Comment #9
metzlerd commentedThis was fixed, commited and pushed.