Jet4中的DateTime和Number格式如何编码? [英] How are DateTime and Number formats encoded in Jet4?

查看:60
本文介绍了Jet4中的DateTime和Number格式如何编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个低级工具来扫描和恢复损坏的Jet4 MDB文件中的数据.我正在浏览页面,解析行和解码列.

I'm writing a low level tool to scan and recover data from damaged Jet4 MDB files. I'm scanning through pages, parsing Rows, and decoding columns.

如果我有Datetime字段的原始8字节值,如何将其转换为日期的字符串表示形式,例如"MM-DD-YY HH:MM:SS"?

If I have the raw 8 byte value for Datetime fields, how can I convert this to a string representation of the date such as "MM-DD-YY HH:MM:SS"?

如果我具有一个具有单个字段大小和3个小数位的Number字段的原始4字节值,该如何将该值转换为float/double?

If I have the raw 4 byte value for a Number field with Single field size and 3 decimal places, how can I convert this value to a float/double?

是否有描述所有访问字段如何编码和存储在磁盘上的文档?

Are there any documents that describe how all of the access fields are encoded and stored on disk?

谢谢.

推荐答案

如果我有Datetime字段的原始8字节值,如何将其转换为日期的字符串表示形式,例如"MM-DD-YY HH:MM:SS"?

If I have the raw 8 byte value for Datetime fields, how can I convert this to a string representation of the date such as "MM-DD-YY HH:MM:SS"?

Access以小字节序格式将日期/时间值存储为64位(8字节)Double值.整数部分表示访问时代"(1899-12-30 00:00:00)之前或之后的天数,小数部分的绝对值表示该天的时间部分 (例如0.5 =正午).因此,例如,在Python中,我们将字节转换为datetime值,如下所示:

Access stores Date/Time values as 64 bit (8 byte) Double values in little-endian format. The integer portion represents the number of days before or after the Access "epoch" (1899-12-30 00:00:00) and the absolute value of the fractional portion represents the time portion for that day (e.g., 0.5 = Noon). So, for example, in Python we would convert the bytes into a datetime value like so:

from datetime import datetime, timedelta
import struct

# bytes as retrieved from .accdb or .mdb file
d_as_bytes = b'\x35\x07\x2F\x2C\x93\x63\xDD\xC0'

d_as_double = struct.unpack('<d', d_as_bytes)[0]  # -30094.29957175926
d_integer_part = int(d_as_double)  # -30094
d_fractional_part = abs(d_as_double - d_integer_part)  # 0.29957175926
access_epoch = datetime(1899, 12, 30)
d = access_epoch + timedelta(days=d_integer_part) + timedelta(days=d_fractional_part)
print(d)  # 1817-08-08 07:11:23

这篇关于Jet4中的DateTime和Number格式如何编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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