Closed AshRaghav closed 7 years ago
Use something like: DateToString(yourdatevalue, "%Y-%m-%d")
Thanks @ebrehault - For some reason it doesn't seem to be working. This is the code for the column
db = context.getParentDatabase()
PdtAvlDateUTC = DateToString(plominoDocument.getItem('PdtAvlStartDate'),"%d/%m/%Y",db)
EvtAvlDateUTC = DateToString(plominoDocument.getItem('EvtStrtDate'),"%d/%m/%Y",db)
return PdtAvlDateUTC or EvtAvlDateUTC
Maybe your value is not a DateTime value. What error do you get ?
Note: the db
param is not needed in your case
@ebrehault - Thanks.
That's the weird part. It is stored as DateTime and I have refreshed the Database a number of times to ensure any column changes are not cached. I have attached screenshots of the data stored here. I can't see any visible errors on the screen now and the logs are clean as well.
I just added db param for additional safety as I usually use DateToString(my_value,None,db) as DB has the universal format we use.
Just to ensure that you have enough information in case this is a bug, this is the Plone environment we are using.
Plone 4.3.3 (4308) CMF 2.2.7 Zope 2.13.22 Python 2.7.6 (default, Jun 2 2016, 08:50:13) [GCC 4.8.4] PIL 2.3.0 (Pillow)
put your db in debug mode and look the server log to see if you get errors
@ebrehault - yes I had done that the logs are still clean with no script errors.
DateToString appears to be working elsewhere in the database but not in this column view. Secondly, when I select the Field from Fields list, the date is appearing correctly in the format set in the database. It is only when I use formula it stops working.
Finally getting this error
AttributeError: 'str' object has no attribute 'toZone'
Context is
However, it doesn't make sense because these are DateTime fields but somehow it is being seen as a string object.
I have another database in the same instance and that seems to work correctly. It was picking up the DateToString conversion without any issues in a view.
Given that - could this be a plomino database issue of some sort? Like something not right with the setup?
@ebrehault - just a quick update.
It has finally started to convert the dates. I mainly changed the Date widget from jQuery one to default, not sure if that helped it. I liked the jQuery version because it looked better.
After several database refresh, the dates have somehow picked up now.
Thanks for your time and suggestions
Hi @ebrehault,
I am not sure what I might be missing here but when trying to display a date in a View using Formulas rather than selecting from the field list renders the date in full DateTime format.
For example, the column in view display 2017/03/29 00:00:00 UTC instead of 29/03/2017.
I have to tried both conversions (StringToDate and DateToString) and both end up with syntax error. The problem I have is to understand the data type of a particular field when being invoked through a column's formula.
Any suggestions here is appreciated.
Thanks