繁体   English   中英

将今天的日期与 dynamodb 表中的日期格式 YYYY-DD-MM 进行比较

[英]comparen today's date with date format YYYY-DD-MM in dynamodb table

我有一个名称表:日期值为 YYYY-DD-MM 的DATETABLEAWS dynamodb中的数据类型为字符串,它具有分区键,日期为字符串

const currentdate = new Date().toISOString().split('T')[0];
client.query({
  TableName: 'date',
  KeyConditionExpression: 'date = :todaydate',
  ExpressionAttributeValues: {
    ':todaydate': currentdate
  }
})

我只想将日期值与当前(今天)日期进行比较,例如使用关键条件

 KeyConditionExpression: 'date = :currentdate',

根据输入返回 true 或 false。 这就像直接查询 SELECT * FROM date WHERE DATE = 2022-14-12(current date) (table value)

错误:意外参数:在 params.ExpressionAttributeValues[':date'] 中发现意外键“7”

尝试:

const currentdate = new Date().toISOString().split('T')[0];
client.query({
  TableName: 'date',
  KeyConditionExpression: 'date = :todaydate',
  ExpressionAttributeValues: {
    ':todaydate': {'S':currentdate}
  }
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM