转换Excel时间格式(自1.1.1901以来的小时数) [英] Converting Excel time-format (hours since 1.1.1901)

查看:133
本文介绍了转换Excel时间格式(自1.1.1901以来的小时数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

来自Microsoft Active Directory集成DNS服务器的区域文件

我获取动态更新条目的日期/时间一个格式,

就我所知的那样,从1901年1月1日开始。

例如:数字3566839是27.11.07 7:00。要在
Excel中计算,我使用:

=" 01.01.1901" +(A1 / 24-(REST(A1; 24)/ 24))+ ZEIT(REST(A1; 24); 0; 0)(在字段A1中放置

3566839并将结果字段的格式切换到

对应的日期时间格式)。


你可能猜到我现在需要的东西:我想以某种方式计算这个
python。


很抱歉,但是我在模块时间内找不到任何东西或其他东西

来计算这个。


有谁知道如何转换这次在python中可以使用什么?b $ b可以使用或者如何在python中转换这个公式?


非常感谢和感谢

Dirk

Hello,

From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.
For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
Excel I use this:
="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) (put
3566839 in field A1 and switch the format of the result-field to the
corresponding date-time format).

You might guess what I need now: I want to calculate this somehow in
python.

Sorry, but I couldn''t find anything in the module time or something
else to get this calculated.

Does anyone know how to convert this time in python to something
usable or how to convert this formula in python?

Thanks a lot and regards
Dirk

推荐答案

12月7日上午7:20,Dirk Hagemann< DirkHagem ... @ gmail.comwrote:
On Dec 7, 7:20 am, Dirk Hagemann <DirkHagem...@gmail.comwrote:

您好,


来自Microsoft Active Directory集成DNS服务器的区域文件

我得到日期/时间Ø f格式的动态更新条目,据我所知,自1901年1月1日以来的小时数为


例如:数字3566839是27.11.07 7 :00。要在
Excel中计算,我使用:

=" 01.01.1901" +(A1 / 24-(REST(A1; 24)/ 24))+ ZEIT(REST(A1; 24); 0; 0)(在字段A1中放置

3566839并将结果字段的格式切换到

对应的日期时间格式)。


你可能猜到我现在需要的东西:我想以某种方式计算这个
python。


很抱歉,但是我在模块时间内找不到任何东西或其他东西

来计算这个。


有谁知道如何转换这次在python中可以使用什么?b $ b可以使用或者如何在python中转换这个公式?


非常感谢和感谢

Dirk
Hello,

From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.
For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
Excel I use this:
="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) (put
3566839 in field A1 and switch the format of the result-field to the
corresponding date-time format).

You might guess what I need now: I want to calculate this somehow in
python.

Sorry, but I couldn''t find anything in the module time or something
else to get this calculated.

Does anyone know how to convert this time in python to something
usable or how to convert this formula in python?

Thanks a lot and regards
Dirk



我想你想在xlrd模块中使用xldate_as_tuple函数:

http://www.lexicon.net/sjmachin/xlrd.htm


它对我来说就像一个冠军:

I think you want the xldate_as_tuple function in the xlrd module:

http://www.lexicon.net/sjmachin/xlrd.htm

It works like a champ for me:


>> import xlrd
xlrd.xldate.xldate_as_tuple(38980,0)
>>import xlrd
xlrd.xldate.xldate_as_tuple(38980,0)



(2006,9,20,0,0,0)

(2006, 9, 20, 0, 0, 0)


>>>
>>>



chad!

chad!


On 7 Dez.,14:34, supercooper< supercoo ... @ gmail.comwrote:
On 7 Dez., 14:34, supercooper <supercoo...@gmail.comwrote:

12月7日上午7:20,Dirk Hagemann< DirkHagem ... @ gmail.comwrote:
On Dec 7, 7:20 am, Dirk Hagemann <DirkHagem...@gmail.comwrote:

Hello,
Hello,


来自Microsoft Active Directory集成DNS的区域文件服务器

我以一种格式获取动态更新条目的日期/时间,据我所知,自从1901年1月1日起的小时数为


例如:数字3566839是27.11.07 7:00。要在
Excel中计算,我使用:

=" 01.01.1901" +(A1 / 24-(REST(A1; 24)/ 24))+ ZEIT(REST(A1; 24); 0; 0)(在字段A1中放置

3566839并将结果字段的格式切换到

对应的日期时间格式)。
From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.
For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
Excel I use this:
="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) (put
3566839 in field A1 and switch the format of the result-field to the
corresponding date-time format).


你可能猜到我现在需要的东西:我想以某种方式在

python中计算。
You might guess what I need now: I want to calculate this somehow in
python.


对不起,但我在模块时间内找不到任何东西或其他东西

来计算这个。
Sorry, but I couldn''t find anything in the module time or something
else to get this calculated.


有没有人知道如何将这段时间在python中转换成可用的东西?b $ b可用或如何在python中转换这个公式?
Does anyone know how to convert this time in python to something
usable or how to convert this formula in python?


非常感谢和问候

Dirk
Thanks a lot and regards
Dirk



我想你想在xlrd模块中使用xldate_as_tuple函数:

http://www.lexicon.net/sjmachin/xlrd.htm


它对我来说就像一个冠军:


I think you want the xldate_as_tuple function in the xlrd module:

http://www.lexicon.net/sjmachin/xlrd.htm

It works like a champ for me:


> import xlrd
xlrd.xldate.xldate_as_tuple(38980,0)
>import xlrd
xlrd.xldate.xldate_as_tuple(38980,0)



(2006,9,20,0,0,0)


chad!


(2006, 9, 20, 0, 0, 0)

chad!



感谢到目前为止,这接近我认为的解决方案,但是当我

输入3566985而不是38980时我收到以下错误:

Traceback(最近一次调用最后一次):

文件" test.py",第20行,< module>

打印xlrd.xldate.xldate_as_tuple(3566985,0)

文件" C:\Python25 \lib \site-packages \ xlrd \ xldate.py",第75行,

xldate_as_tuple

筹集XLDateTooLarge(xldate)

xlrd.xldate.XLDateTooLarge:3566985


我有吗使用这个模块的另一个功能?我的号码比你的数字短2 / b
。什么是38980代表?


Dirk

Thanks so far, that comes close to a solution I think, BUT when I
enter 3566985 instead of 38980 I get the following error:
Traceback (most recent call last):
File "test.py", line 20, in <module>
print xlrd.xldate.xldate_as_tuple(3566985,0)
File "C:\Python25\lib\site-packages\xlrd\xldate.py", line 75, in
xldate_as_tuple
raise XLDateTooLarge(xldate)
xlrd.xldate.XLDateTooLarge: 3566985

Do I have to use another function of this module? My number is 2
digits shorter than yours. What is 38980 representing?

Dirk


12月7日,7:20 ??? am,Dirk Hagemann< DirkHagem ... @ gmail.comwrote:
On Dec 7, 7:20???am, Dirk Hagemann <DirkHagem...@gmail.comwrote:

Hello,


来自Microsoft Active Directory集成DNS的区域文件服务器

我以一种格式获取动态更新条目的日期/时间,据我所知,自从1901年1月1日起的小时数为
.
Hello,

From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.



您的猜测似乎已经过了几个世纪。


(3566839/24)/ 365 = 407

Your guess appears to be off by a couple centuries.

(3566839/24)/365 = 407


例如:数字3566839是27.11.07 7:00。要在
Excel中计算,我使用:

=" 01.01.1901" +(A1 / 24-(REST(A1; 24)/ 24))+ ZEIT(REST(A1; 24); 0; 0)???(在字段A1中放置

3566839并将结果字段的格式切换为

对应日期时间格式)。


你可能猜到我现在需要的东西:我想以某种方式计算这个
python。

对不起,但我在模块时间内找不到任何东西或其他东西

来计算这个。


有谁知道如何将这段时间在python中转换为某种东西

可用或如何在python中转换这个公式?


非常感谢和关心

Dirk
For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
Excel I use this:
="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) ???(put
3566839 in field A1 and switch the format of the result-field to the
corresponding date-time format).

You might guess what I need now: I want to calculate this somehow in
python.

Sorry, but I couldn''t find anything in the module time or something
else to get this calculated.

Does anyone know how to convert this time in python to something
usable or how to convert this formula in python?

Thanks a lot and regards
Dirk


这篇关于转换Excel时间格式(自1.1.1901以来的小时数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆