在 SQLite for Android 中插入时间戳 [英] Insert TimeStamp in SQLite for Android

查看:46
本文介绍了在 SQLite for Android 中插入时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下字段

<前>1> 作品名称 - Varchar2> 时间标记

我想用上述字段创建一个表.

  1. TimeStamp 数据类型是什么

  2. 如何向表中插入时间戳值.

  3. 插入数据时时间戳值是什么或如何获取时间戳.

我曾在 SQLite 上工作过,但没有任何将时间戳作为字段添加到表中的经验 &增加价值.

什么样的CREATE &我应该使用 INSERT 语句吗?

解决方案

Sqlite 数据库中可用的数据类型有限,所以我认为对日期有用的是整数 - 这将接受长值(动态调整其大小),因此日期存储日期的毫秒值,当从数据库中读取毫秒值时,可以轻松地重新构造日期.

I have the following fields

1> WorkName - Varchar

2> TimeStap 

I wanted to create a Table with the above fields.

  1. What will be the TimeStamp datatype

  2. How can I insert timestamp values to the table.

  3. What will the timestamp value while inserting data or how to fetch the timestamp.

I have worked on SQLite but don't have any experience on adding TimeStamp as a field to the table & adding values to that.

What kind of CREATE & INSERT statements should I use?

解决方案

There are limited datatypes available in a Sqlite Database, so the one I find useful for dates is integer - this will accept long values (dynamically adjusts its size) so for dates store the milliseconds value of a date and the date can be easily reconsituted when reading the millisecond values back out of the database.

这篇关于在 SQLite for Android 中插入时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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