[Numpy-discussion] just the date part of a datetime64[s]?

John Salvatier jsalvati@u.washington....
Wed Feb 8 11:10:37 CST 2012

Hello, is there a good way to get just the date part of a datetime64?
Frequently datetime datatypes have month(), date(), hour(), etc functions
that pull out part of the datetime, but I didn't see those mentioned in the
datetime64 docs. Casting to a 'D' dtype didn't work as I would have hoped:

In [30]: x= datetime64('2012-02-02 09:00:00', 's')

In [31]: x
Out[31]: numpy.datetime64('2012-02-02T09:00:00-0800')

In [32]: x.astype('datetime64[D]').astype('datetime64[s]')
Out[32]: numpy.datetime64('2012-02-01T16:00:00-0800')

What's the simplest way to do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120208/c7df5118/attachment.html 

More information about the NumPy-Discussion mailing list