【问题标题】:SQL composite key from datetime functions来自日期时间函数的 SQL 复合键
【发布时间】:2012-04-19 18:54:41
【问题描述】:

我正在尝试使用 SQLite 的一些函数创建一个复合键,但列 'newdate' 和 'newckey' 并且在我运行查询时显示为空白。有什么建议吗?

SELECT *,
       (repeat||date) as 'ckey', 
       (repeat||newdate) as 'newckey' 
FROM (SELECT transactions.id,
             transactions.repeat,
             transactions.date, 
             datetime(transactions.date,'+'||repeattransactions.interval||' days') 
                   AS 'newdate' 
      FROM transactions, repeattransactions 
      WHERE transactions.repeat = repeattransactions.id
     )

【问题讨论】:

  • date 和 newdate 已经是字符串类型了吗?
  • 没有日期是 sqlite DATE 类型
  • 但我看不出这会有什么不同,请参阅stackoverflow.com/questions/3018018/…
  • 哎呀!只需仔细检查我的日期格式,我也有无关的时区信息!

标签: sql sqlite datetime composite-key


【解决方案1】:

SQL 本身没有问题,日期以错误的格式存储,包括本地时区信息

【讨论】:

    猜你喜欢
    • 2016-04-02
    • 2018-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 2011-11-09
    • 2019-02-27
    • 1970-01-01
    相关资源
    最近更新 更多