Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I see from previous issues there is a problem with "date" module fields and this module..
Will this module ever support date fields?
or is there a problem with supporting "date" fields?
Seems to me that the usefulness of this module will be massively increased if date module fields were supported..
Thanks..
Comments
Comment #1
zany CreditAttribution: zany commentedIt worked with a previous version of the Date module. Restructuring in that module made a big rewrite necessary. A simple hack won't do anymore. I estimate this at 100-200 LoC.
Patches or sponsoring welcome.
Comment #2
wipeout_dude CreditAttribution: wipeout_dude commentedHmmm.. Approximately how much would it cost to sponsor this work?? I might be able to contribute to the costs..
Comment #3
zany CreditAttribution: zany commentedComment #4
naeluh CreditAttribution: naeluh commentedI would appreciate this functionality also
let me know how I can help
Comment #5
zany CreditAttribution: zany commentedNick, coordinate with Ranko and wipeout_dude to get this sponsored.
Comment #6
naeluh CreditAttribution: naeluh commentedOk I will try thanks Do you think they are in the irc?
Comment #7
joaomachado CreditAttribution: joaomachado commentedYes, I too would like to see this module support Date module fields. I would be willing to sponsor what I can.
Comment #8
pav CreditAttribution: pav commented+1
Comment #9
mpisano CreditAttribution: mpisano commented+1
Comment #10
windmaomao CreditAttribution: windmaomao commented+1, how does sponsorship work here ? we might be able to here as well.
Comment #11
wipeout_dude CreditAttribution: wipeout_dude commentedThe module maintainer is looking for 300 Euro..
I can contribute $50..
Comment #12
yannisc CreditAttribution: yannisc commentedI can contribute 50$ as well. We need 4 more.
Comment #13
wipeout_dude CreditAttribution: wipeout_dude commentedWell 6 more.. I think 300 Euro is just under US$400.. :)
Comment #14
yannisc CreditAttribution: yannisc commentedYou are right!
Comment #15
laboratory.mikeI'll chip in $200. I need this also.
Comment #16
iaminawe CreditAttribution: iaminawe commentedI can chip in another $50 towards this development work - I need this feature too
Thanks
Gregg
Comment #17
paranojik CreditAttribution: paranojik commentedI've played a bit with this problem and I think I got the basic functionality working (at least for the use cases I've tested).
I have basically just extended the 'views_handler_field_field' handler that is normally used for date field and changed the bits that apply to the 'format_date_sql' functionlity. Otherwise it should fallback to the default 'views_handler_field_field' handler behavior.
Comment #18
zany CreditAttribution: zany commentedThanks Tadej. Looks good, but I won't have time to really test this for at least a few weeks. Maybe we can get some community opinions on it.
Comment #19
RoSk0Patch from #17 works great for me.
Ready to test, but need use cases.
Comment #20
heddnI didn't have a bunch of time to troubleshoot, but applying the patch broke my date handlers.
Comment #21
heddnOk, part of my problem in #20 was the patch didn't apply cleanly. I manually applied the patch and things started to work.
Performance Note:
I'm using the same date field in different formats to build up a file path in my public files folder to print a URL to PDF documents i.e. sites/defaults/files/reports/2013/06/updates.pdf, sites/defaults/files/reports/2013/06/research.pdf, etc. The date is the same date field. So, this results in multiple fields being returned from the DB. Previously this would only be a single field with render() formatting thrown on top of it. This doesn't really matter to me, but it might have an effect on others.
Marking RTBC.
Comment #22
cialog CreditAttribution: cialog commentedCan someone pls link to a patched module zip. The #17 patch didn't work for me and I want to help testing.
Comment #23
paranojik CreditAttribution: paranojik commentedYou have to apply to the "master" branch, which I suppose is the -dev version. Anyway, here's the patched version.
Comment #24
lunk rat CreditAttribution: lunk rat commentedPatch in #17 applied to master branch is mostly working, but has an issue with timezone handling: If I create a node with a date field that has Y-m-d granularity, enter 06/01/2013, it gets created as 2013-06-01 00:00:00.
When an aggregation-enabled views field with "Use SQL to format date" turned on, this field value 2013-06-01 00:00:00 gets rendered as an aggregate grouping for 2013-05 or "May 2013".
I remember coming across this bug in a handful of other modules (Entity tokens, Feeds) and it has to do with the timezone handling and handling of the hour/minute/seconds on the date value.
Once this headache is sorted, I am happy using this patch. Thank you!
Comment #25
Exploratus CreditAttribution: Exploratus commentedpatch worked for me. Although my dates on the x axis are in alphabetical order, rather than sequential from oldest to newest.
Comment #26
lunk rat CreditAttribution: lunk rat commented@Exploratus: try adding a sort criteria for that date field. If it breaks your aggregation, change the sort criteria's aggregation settings to "Minimum" and see if that helps.
Comment #27
lunk rat CreditAttribution: lunk rat commentedI temporarily fixed my timezone issue by setting the site's default timezone to UTC (not ideal, but works!)
Please advise on how to improve timezone handling in Views Date Format SQL
Thanks for the awesome module.
Comment #28
Exploratus CreditAttribution: Exploratus commentedThanks @lunk_rat. It worked with minimum in the sort.
Comment #29
DMex CreditAttribution: DMex commentedI was trying to use this to format dates for google charts tools module to prevent timestamp of 00:00:00 appearing - However I wanted the input to be pasted on a custom date field.
I found a work around that worked for me, Views Raw SQL
By formatting the at the SQL layer, I was able to get exactly what I needed.
CAST(field_data_field_kpi_date.field_kpi_date_value AS DATE)
in my example.
Also given the amount of documentation for SQL (and in particular MySQL) date formatting, hopefully an easy for those who don't use SQL.
my first post on drupal
Comment #30
lunk rat CreditAttribution: lunk rat commentedDMex:
Thanks for the pointer on Views Raw SQL module.
AND welcome to drupal.org!
Comment #31
MustangGB CreditAttribution: MustangGB commentedRTBC #17
Comment #32
WorldFallz CreditAttribution: WorldFallz commentedFYI #23 totally fails with sqlserver using sqldrv-- the date field is simply missing from the query:
Note how views/date handle year granularity in an exposed filter for a date field-- it's correctly translated into sqlsrv syntax. I'm trying to trace this down, but any ideas of where to look would be greatly appreciated.
Comment #33
TheoRichel CreditAttribution: TheoRichel commentedI am trying to make a View with either Start Date or End Date (as used in the Rooms module), but the application of the file in nr 23 doesnt change anything for me: the checkbox does not appear in the configuration box of these fields.
And as to the talk here of the master branch and dev versions.... there currently is only one version of this module afaik.
Comment #34
skorzh#17 works good for me, thanks a lot!
Comment #35
skorzhTested better, and this patch doesn't work with Date (Unix timestamp) field type.
I changed #17 patch to fix it.
Comment #36
AndrewsizZ CreditAttribution: AndrewsizZ commentedFor me #35 patch works good!
Comment #37
rkent_87 CreditAttribution: rkent_87 commentedOk I am a total idiot but I don't get how to apply this
Comment #38
RoSk0@rkent_87: Try to use
patch -p 1 < /full/path/to/file/views_date_format_sql-date_field_support-1830436-35.patch
Comment #39
xatiu CreditAttribution: xatiu commentedHello when a delta of multiple date field is inserted in a view and I use views_date_format_sql (version included in comment #23) the sql query fails because of a field "node. AS node_" in views sql query. Do you have any thoughts?
Thank you.
Comment #40
vinothg CreditAttribution: vinothg commentedAdding a new condition to check for date module fields, fixed the issue for me.
Thanks,
Vinoth
Comment #41
fuzzy76 CreditAttribution: fuzzy76 commentedIf the patch needs a patch, someone needs to reroll so we can retest I guess. (#35 and #40 combined)
Comment #42
m.lebedev CreditAttribution: m.lebedev commentedOne patch for a user and second for a developer. The problem in the file .info. The failed to apply the patch due to a timestamp and version of the module.
Comment #43
eabquina CreditAttribution: eabquina commentedFinally successful on manually applying the patch. No more Broken Handlers for fields that I used.
It seems that i need to Flush all Caches first after applying the patch....
I tested with the following set-up;
Built 2 Date formats, Monthly Format (y-M) and Daily Format (Y-M-d)
I'll be building Views using Table, Chart (charts_highcharts), and Table with Aggregation options (Views Aggregate Plus)
3 fields Content: Post Date, Content: Custom_Date(
It works perfectly if I use it for Table with Aggregation options format. for the Daily and Monthly Format. (using a custom Date Format, or a Regional Settings )
I am really having trouble using Table and Charts and it doesnt work properly, no aggregation. (I just want to make a line graph of created nodes per Day :) )
Here's what the SQL query generates.
SELECT node.created AS node_created_1, DATE_FORMAT((DATE_ADD('19700101', INTERVAL node.created SECOND) + INTERVAL 28800 SECOND), '%Y-%b-%d') AS node_created, COUNT(node.nid) AS nid
FROM
{node} node
WHERE (( (node.status = '1') AND (node.created > 1432409672) ))
GROUP BY node_created, node_created_1
ORDER BY node_created_1 ASC
Should the GROUP BY field also have a DATE_FORMAT convert with the format "Y-M-d".
I will try to revert to the unpatched version and see if still the same.
Comment #44
eabquina CreditAttribution: eabquina commentedI noticed that the raw SQL query adds another field node.created as node_created_1, so the table looks like this:
node_created_1 | node_created | nid
1432413881 | 2015-May-24 | 1
1432414239 | 2015-May-24 | 1
1432412412 | 2015-May-24 | 1
(and also included in the group by statement). No aggregation made.
I tried to make raw query tests, it should be only like this;
node_created | nid
2015-05-24 | 185
2015-05-25 | 231
2015-05-26 | 174
It works great. I start to see the list I want.
---
I hope this makes sense... what should be the next step here?
IF we can somehow remove this unnecessary column, and correct the GROUP BY line to only use the one with the "DATE_FORMAT", (and arrange the sequence of the fields"
Comment #45
eabquina CreditAttribution: eabquina as a volunteer commentedAdding more to my observations;
The aggregation breaks if we add a SORT CRITERIA
Make sure to use Numerical format, as it works well with the default sorting
I think this should confirm the patch works fine :)
Comment #46
ferriol CreditAttribution: ferriol commentedI test the patch #42, and works great for me, thanks !
Comment #47
fox_01 CreditAttribution: fox_01 commentedAfter applying #42 and flushing the caches i get
the includes folder contains the following files
-rw-r--r-- 1 root root 1931 Jan 15 09:57 views_date_format_sql_handler_date_field.inc
-rw-r--r-- 1 root root 1830 Jan 15 09:57 views_date_format_sql_handler_date.inc
EDIT:
I had to restart apache which runs with an apc cache. Now the error is gone
Comment #48
katrien_w CreditAttribution: katrien_w commentedIs there a trick to make it work with charts?
Comment #49
fox_01 CreditAttribution: fox_01 commentedIs there a patch for latest stable 7.x-3.3?
Comment #50
ron_s CreditAttribution: ron_s commentedHere is an updated patch. This is a somewhat different... it takes into account the changes made in 7.x-3.2 and 7.x-3.3 to improve the performance of
views_date_format_sql.views.inc
. Please let me know if there are any issues.Also the module branches need to be fixed. Right now, master is pointed at 7.x-3.2, and 7.x-3.3 is it's own tag. @zany, I'd appreciate if you can get this resolved, thanks.
Comment #51
progalla CreditAttribution: progalla commentedI run into an error while patching the module (7x-3.3).
views_date_format_sql.info.rej:
After patching views_date_format_sql.info manually I can confirm that the patch is working for me.
Comment #52
ron_s CreditAttribution: ron_s commented@progalla, I cannot reproduce your error. I downloaded a clean copy of 7.x-3.3, re-applied patch #50, and have no issues.
Were you possibly using a copy of 7.x-3.2, or had you upgraded from 3.2 to 3.3? I'd appreciate if you could download a clean copy and see if you can cause it to happen again. I'm not seeing any problems.
Comment #53
trenttati CreditAttribution: trenttati commentedI had the same patching error and was able to resolve it by removing the single space on line 248 of the patch file. The error was encountered using the command "patch -p1 < views_date_format_sql-date_field_support-1830436-50.patch" on Ubuntu Server 14.04.
Comment #54
ron_s CreditAttribution: ron_s commentedVery odd, I know that patch applied cleanly at some point in the past. Not sure what changed. Here is a new version, and below is confirmation that it is patching cleanly.
Comment #55
mbolli CreditAttribution: mbolli as a volunteer commented#54 failed for me for 3.3:
after applying it manually, it works though.
Comment #56
ignelius CreditAttribution: ignelius commentedEvery time I try to patch in cygwin I get the message:
Any ideas?
I looked at manually patching but it's got me stumped...
Thanks
Comment #57
ron_s CreditAttribution: ron_s commented@ignelius, not sure what to tell you, I don't use cygwin. The file has to exist, it's part of the module: http://cgit.drupalcode.org/views_date_format_sql/tree/includes/views_dat...
Maybe you're not patching from the right location in the directory.
Comment #58
ignelius CreditAttribution: ignelius commentedThanks @ron_s
Yes the file is definitely there.
I downloaded the patch file into the module folder, navigated there in cygwin and then input:
patch -p0 < views_date_format_sql-date_field_support-1830436-54.patch
And get the error message above (#56).
I'm doing this on an isolated module folder (ie: outside of a drupal installation), maybe that's the problem.
If anyone's familiar with CygWin would really appreciate any tips, thank you.
Or a patched version of the module for download would be proper awesome ;)
Comment #59
ignelius CreditAttribution: ignelius commentedI tried #29 and it worked for my situation, thanks.
Comment #60
fuzzy76 CreditAttribution: fuzzy76 commented@ron_s Your 3.3 must be different from the download on the project page or something... Could it be that the 3.3 tag is moved? Both #50 and #54 fails on the 3.3 download from d.o.
Comment #61
ron_s CreditAttribution: ron_s commented@fuzzy76, patches are never written against code downloaded from the project page. They are pulled from a Git version control branch:
https://www.drupal.org/project/views_date_format_sql/git-instructions
Comment #62
fuzzy76 CreditAttribution: fuzzy76 commented@ron_s I was confused by the fact that you in #50 said the patch was based off work in both 3.2 and 3.3, and in #52 said you applied it to a downloaded copy of 3.3. But the master branch only contains 3.2.
Comment #63
ron_s CreditAttribution: ron_s commented@fuzzy76, please see the comment I made in #50:
A patch can only be created against what is available in git as a branch, and there is no 7.x-3.x-dev branch to work against. As I said in follow-up comments, I am able to get the patch to apply cleanly to 7.x-3.2 and 7.x-3.3. However, I wouldn't be surprised if some others might have issues if they don't have a similar dev environment to mine.
The reality is until @zany (or @joelpittet, or someone else) actually updates the master branch or creates a formal 7.x-3.x-dev branch, and your environment does not allow you to patch the module cleanly, you'll have to do it manually.
Comment #65
zany CreditAttribution: zany commented@ron_s, I didn't catch #50, sorry. Fixed. I also put your patch #54 into 7.x-3.x so it's easier to test and hopefully RTBC.
Comment #66
ron_s CreditAttribution: ron_s commentedThank you @zany!
Comment #67
ron_s CreditAttribution: ron_s commentedAlso setting to 7.x-3.x-dev, so everyone knows they should be testing against this version.
Comment #68
Alex Bukach CreditAttribution: Alex Bukach commentedAccording to https://www.drupal.org/node/998076 date fields are not converted to UTC when being stored to database., and therefore I get shifted results when I use _Views Date Format SQL_ formatting. Probably we should force the offset to be zero for the fields.
Comment #69
potassiumchloride CreditAttribution: potassiumchloride commentedConfirming that 7.x-3.x works for me with a Date field.
For others who stumble onto this post: If you don't see a check box for "Use SQL to format date" when you configure the date field in your view, make sure you use the -dev branch of the module. Then, if using a Sort for your date field breaks the aggregation, use the tip in #26 and set the aggregation to "Minimum" instead of "Group results together."
Comment #71
zany CreditAttribution: zany commentedThanks for the fix @alex-bukach. Pushed to 7.x-3.x.
Can anyone else using this report it working like @potassiumchloride -- a few satisfied users and I'll finally mark this stable.
Comment #72
dtamajon CreditAttribution: dtamajon commentedThe patch is supposed to be working with unixtimestamp date? I haved tested 7.x-3.x-dev and is not working for me. I tried #26 and neither worked.
Comment #73
P2790 CreditAttribution: P2790 commentedI do not see the check box even when following #69
Comment #74
rkent_87 CreditAttribution: rkent_87 commentedWhere is the checkbox supposed to appear? I'm using the dev branch and I've cleared the cache.
Comment #75
P2790 CreditAttribution: P2790 commentedAny Updates?
Comment #76
ron_s CreditAttribution: ron_s commentedThe 7.x-3.x-dev version accurately reflects patch #54. I'm also attaching a minor patch to fix a couple of typos I had in the original. Thanks.
@rkent87, it has to be on a date content field created using the Date module. From your screen shot, it doesn't look like that's your source. See my attached image.
Comment #77
P2790 CreditAttribution: P2790 commentedThanks
Comment #79
fuzzy76 CreditAttribution: fuzzy76 commentedAny chance of getting this released any time soon? Getting these patches applied to a stable release is a major pain. :-/
Comment #80
zany CreditAttribution: zany commented@fuzzy76 the 7.x-3.x-dev is at the latest patch.
Comment #81
fuzzy76 CreditAttribution: fuzzy76 commentedYes, but I won't use dev releases in production.
Comment #82
zany CreditAttribution: zany commentedWell, if that's the policy. Pull the 3 commits (labeld "Issue #1830436") from the 7.x-3.x git and apply on top of the 7.x-3.3 tag. This will give you the same source without using -dev. Or even quicker: use 7.x-3.x and reset --soft HEAD^^, maybe.
Comment #83
zany CreditAttribution: zany commentedOr maybe pin your drush make to 2dc5920. Otherwise this issue just needs a few solid RTBC to be released.
Comment #84
CProfessionals CreditAttribution: CProfessionals commentedInstalling Dev fixed the issue with the checkbox showing. Thank you
Comment #85
AporieSimply a reroll of #54 + #76 for 3.3
Comment #86
AlfTheCat CreditAttribution: AlfTheCat commentedUpdated to latest dev and seems to be working great, using date fields on field collections.
Thanks!
Comment #87
kobusvw CreditAttribution: kobusvw commentedWhen will Drupal 9 be available for this module?
Comment #88
zany CreditAttribution: zany commentedThis module was a quick hack until Views picked this needed change up -- 10 years ago. There was never a stable 8.x release and I don't "envision" a 9.x release. I'm not using this feature anymore. If there are tested patches or RTBC I'll merge that anytime, though.
Comment #89
bluegeek9 CreditAttribution: bluegeek9 as a volunteer commented