Web2py / Pydal Time Fields

79 views
Skip to first unread message

Mark Graves

unread,
Nov 5, 2015, 12:53:05 AM11/5/15
to web2py-users
Hey everyone,

I find myself in the need for microsecond level precision for time fields where I am querying over those fields regularly.

As I dug into pydal and web2py's internals, I noticed that it seems to be convention that times are truncated to H:M:S

I'm aware I can easily store as a string and coerce or define a custom field type or store as a datetime for the required precision.

I'm finding that rather cumbersome.

Am I missing something or would this be the best way to approach this?

-Mark

Manuele Pesenti

unread,
Nov 10, 2015, 2:19:02 AM11/10/15
to web...@googlegroups.com
Il 05/11/15 06:53, Mark Graves ha scritto:
I was interested to read some answers to this question too... I would
try to save the micro-seconds part of your datetime in a different column
Let me know if this approach can fit to your needs.

Best regards

Manuele

Mark Graves

unread,
Nov 10, 2015, 4:39:59 AM11/10/15
to web...@googlegroups.com
I ended up converting to Decimal and then working from there.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Iaklk67GzIw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Manuele Pesenti

unread,
Nov 10, 2015, 9:53:40 AM11/10/15
to web...@googlegroups.com
Il 10/11/15 10:39, Mark Graves ha scritto:
> I ended up converting to Decimal and then working from there.
ok, not so far from my approach... you don't need to manage timezone I
guess.

Cheers

M.

Mark Graves

unread,
Nov 10, 2015, 10:16:31 AM11/10/15
to web...@googlegroups.com
No, thankfully everything was done in one timezone =)

Massimo Di Pierro

unread,
Nov 11, 2015, 10:25:03 AM11/11/15
to web2py-users
in retrospect this was a poor design decision, but we cannot change it for backward compatibility.

Anthony

unread,
Nov 11, 2015, 11:54:42 AM11/11/15
to web2py-users
On Wednesday, November 11, 2015 at 10:25:03 AM UTC-5, Massimo Di Pierro wrote:
in retrospect this was a poor design decision, but we cannot change it for backward compatibility.

Maybe we should add a new field type (e.g., "time_with_ms" or "ms_time").

Anthony

Mark Graves

unread,
Nov 11, 2015, 11:58:10 AM11/11/15
to web...@googlegroups.com
What about changing the format specification to allow for the format so you could still have the time there.

The only problem I thought I saw is that stripping off ms is built into a number of pydal adapters (I think -- might be wrong)

With that, it would in theory allow backward compatibility for anyone else's data.

-Mark

--
Reply all
Reply to author
Forward
0 new messages