You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将数值型数据转换为yyyymmddhh24miss格式时间戳求助

数值型时间戳转yyyymmddhh24miss格式解决方案

场景1:SQL环境(以MySQL/PostgreSQL为例)

源数据的整数部分正好是目标格式的14位字符,只需将数值转字符串后截取前14位即可:

-- MySQL
SELECT SUBSTRING(CAST(your_column AS CHAR), 1, 14) AS formatted_timestamp
FROM your_table;

-- PostgreSQL
SELECT SUBSTRING(your_column::text, 1, 14) AS formatted_timestamp
FROM your_table;

场景2:Python处理

单个数值转换

num_timestamp = 20220929121001.0000000
formatted = str(int(num_timestamp))
print(formatted)  # 输出:20220929121001

Pandas批量处理DataFrame

import pandas as pd

df = pd.DataFrame({'timestamp': [20220929121001.0000000, 20220919085939.0000000]})
df['formatted_timestamp'] = df['timestamp'].astype(int).astype(str)

场景3:Java处理

double numTimestamp = 20220929121001.0000000;
String formatted = String.valueOf((long) numTimestamp);
System.out.println(formatted);  // 输出:20220929121001

内容的提问来源于stack exchange,提问作者BalajiAWS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 10:00:54