.dtq 文件查询 .dbf 的 SQL 语法

发布于 2024-10-14 20:01:43 字数 429 浏览 0 评论 0原文

在 Microsoft Visual Studio 2008 Pro Edition 中使用最新的 Visual Fox Pro OLE DB 提供程序。我无法在 *.dtq 文件中使用 SQL 函数。我有超过 181 个 *.dtq 文件,我最终需要从 sqlscript 调用这些文件,但我的问题在于尝试解析 dbf 文件中的列时。我需要的列包含一个时间,即。 HH:MM:SS 我需要能够解析时间列以仅提取小时或分钟。分钟将以 15 分钟为间隔进行划分,因此,只要时间 > 15 分钟,我就可以拉动。大于 0 但 < 15 这样我就可以每隔 15 分钟提取一次数据。通常我会使用像parse或parsname或split或decim或decim这样的函数,或者说转到字符空间#然后是#字符空间。就像在 dos 中一样,我可以使用 %TIME:~3,2% 来提取包含我需要的时间信息的列的分钟部分所需的信息。请帮我。提前谢谢您。

Using the latest Visual Fox Pro OLE DB Provider inside Microsoft Visual Studio 2008 Pro Edition. I cannot use SQL functions inside my *.dtq files. I have over 181 *.dtq files that I ultimatley need to call from a sqlscript but my problem lies when attempting to parse a column in a dbf file. The column that I need contains a time ie. HH:MM:SS I need to be able to parse the time column to pull just the hour or minutes. The minutes will be sectioned in 15 minute intervalls so ie for 15 on the hour I can pull as long as time is > than 0 but < 15 so that I can pull data for 15 minute intervals. Usually I would use a function like parse or parsname or split or decimal or decim or something that says go to character space # and then # character spaces after that. Like in dos i can use %TIME:~3,2% to pull information I need for the minute section of the column that contains the time inforamtion that I need. Please help me. Thank you in advanced.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野鹿林 2024-10-21 20:01:43

虽然我并不直接熟悉 .dtq 文件(除非它们只是重命名的 .dbf 文件),但 VFP 具有日期/时间函数来为您获取日期字段的不同组成部分。但是,仅“TIME”组件没有数据类型。它通常只是存储为字符串(字符)列。但是,如果列是日期/时间,您可以使用

HOUR( YourDateTimeColumn ) -- will return based on 24 hour clock... 1pm = 13, 2pm = 14, etc
MINUTE( YourDateTimeColumn )

但是,您的示例显示 HH:MM:SS,因此我将仅存储为字符串。所以我会通过...

select 
      val( left( YourTimeColumn, 2 )) as MyHour,
      val( substr( YourTimeColumn, 4, 2 )) as MyMinutes,
      int( val( substr( YourTimeColumn, 4, 2 )) / 15 ) as QtrMinute
   from
      YourTable

稍微偏离你的>来得到它。 0且< 15 并不代表真正的 15 分钟,而是 14,

0 - 14 minutes = 1st quarter minute
15- 29 minutes = 2nd quarter minute
30- 44 minutes = 3rd quarter minute
45- 59 minutes = 4th quarter minute

如果您想要基于 1-15 分钟、16-30、31-45、46-60 的季度,则更改为
int( 1+val (...) 作为 QtrMinute

Although I'm not directly familiar with .dtq files (unless they are just .dbf files renamed), VFP has date/time functions to get different components of a date field for you. However, there is no data type for just "TIME" component. Its typically just stored as a string (character) column. However, if the column IS of a date/time, you can use

HOUR( YourDateTimeColumn ) -- will return based on 24 hour clock... 1pm = 13, 2pm = 14, etc
MINUTE( YourDateTimeColumn )

However, your example shows HH:MM:SS, so I'm going with stored as just a character string. So I would get it by...

select 
      val( left( YourTimeColumn, 2 )) as MyHour,
      val( substr( YourTimeColumn, 4, 2 )) as MyMinutes,
      int( val( substr( YourTimeColumn, 4, 2 )) / 15 ) as QtrMinute
   from
      YourTable

Slightly off of your > 0 and < 15 which doesn't represent a true 15 minutes, but 14,

0 - 14 minutes = 1st quarter minute
15- 29 minutes = 2nd quarter minute
30- 44 minutes = 3rd quarter minute
45- 59 minutes = 4th quarter minute

If you want the quarters based on 1-15 minutes, 16-30, 31-45, 46-60, then change to
int( 1+val (...) as QtrMinute

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文