无法查询表存储中的DateTime列 [英] Cannot query a DateTime column in Table Storage

查看:57
本文介绍了无法查询表存储中的DateTime列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从Logic App中使用formatDateTime()将一列插入表存储中,并且在查看记录时输入了正确的值,并且列类型显示为DateTime:

I have inserted a column into table storage using formatDateTime() from within a Logic App and the correct value is entered and the column type is displayed as DateTime when I view the record:

但是,当我尝试在此字段上查询时,它默认为字符串,即使将其更改为DateTime时也不会返回结果.

However when I try to query on this field it defaults to string and even when I change it to DateTime it returns no results.

我没有尝试在formatDateTime()中使用任何格式,标准格式和自定义格式,但没有任何方法可以带回结果.关于我所缺少的任何想法吗?

I have tried no formatting, standard formats and custom formats in the formatDateTime() but nothing will bring back results. Any ideas as to what I am missing?

推荐答案

根据一些测试,该值仍在"字符串"输入但不输入" DateTime "类型.此

According to some test, the value is still in "String" type but not "DateTime" type. This document shows us the method formatDateTime() response a value in string.

因此,当我们从方法 formatDateTime()中插入值时,它将在存储表中插入一个字符串.似乎在azure门户的显示中有一个错误,它显示类型为" DateTime ".但是,如果我们在" Azure Storage Explorer "中打开表存储,但不在Azure门户上,我们可以在"字符串"中找到新插入记录的 TimeOfCreation .类型.

So when we insert the value from method formatDateTime(), it will insert a string into the storage table. It seems there is a bug in display of azure portal, it shows the type is "DateTime". But if we open the table storage in "Azure Storage Explorer" but not on Azure portal, we can find the TimeOfCreation of new inserted record is in "String" type.

对于此要求,很难获得" DateTime "在逻辑应用程序中键入value并将其插入表存储中.我们可以只插入一个字符串.但是在将新记录插入表存储之后,我们可以编辑类型.我们可以在Azure门户或" Azure Storage Explorer "中进行操作.如果要在Azure门户上执行此操作,只需单击"编辑"记录,然后点击"更新";按钮不执行任何操作(因为该类型已经显示为"DateTime").如果在" Azure Storage Explorer "中执行此操作,只需将类型从"字符串"更改为到" DateTime "并点击"更新".之后,我们可以通过"TimeOfCreation"查询记录.> =最近365天成功.

For this requirement, it's difficult to get a "DateTime" type value in logic app and insert it into table storage. We can just insert a string. But we can edit the type after insert the new record to table storage. We can do it on Azure portal or in "Azure Storage Explorer". If do it on Azure portal, just click "edit" the record and click "Update" button without do anything(because the type already show as "DateTime"). If do it in "Azure Storage Explorer", just change the type from "String" to "DateTime" and click "Update". After that, we can query the records by "TimeOfCreation" >= Last 365 days success.

不好的是,我们可以只对每个插入的记录进行手动操作.我们无法在逻辑应用程序中解决此问题,也无法批量更新类型(在门户网站或资源管理器中).如果要批量更新类型,则可以通过 api (使用$ filter过滤时间戳).然后获取每个记录的 PartitionKey RowKey ,并循环它们.使用此 api 来更新列TimeOfCreation 类型.

The bad thing is, we can just do it manually on each inserted record. We can't solve this problem in logic app or batch update the type(on portal or in explorer). If you want to batch update the type, you can query all of the new inserted records by this api (use $filter to filter timestamp). And then get each record's PartitionKey and RowKey, and loop them. Use this api to update the column TimeOfCreation type.

这篇关于无法查询表存储中的DateTime列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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