如何解决在psql 12中以文本格式比较时间
// disable this if you're already using the command below.
// This can cause `command` to be defined twice and return a constant value error.
// const commandFiles = fs
// .readdirsync('./commands/')
// .filter(file => file.endsWith('.js'));
// for(const file of commandFiles){
// const command = require(`./commands/${file}`);
// client.commands.set(command.name,command);
// }
client.on('ready',() => {
// `client.on()` should be better
console.log('ChatSlowMode is Online!');
});
client.on('message',(message) => {
// Check if message doesn't starts with `prefix` instead,or it will stop your code.
if (!message.content.startsWith(prefix) || message.author.bot) return;
const command = message.content
.slice(prefix.length)
.toLowerCase()
.split(' ')[0]
.toLowerCase();
const args = message.content
.slice(prefix.length)
.split(' ')
.slice(1);
if (command === 'slowmode') {
if (!message.member.hasPermission('MANAGE_CHANNELS'))
return message.channel.send("You don't have access to this command!");
// Checks if `args[0]` doesn't exist or isn't a number.
if (!args[0])
return message.channel.send('You did not specify a correct amount of time!');
if (isNaN(args[0])) return message.channel.send('That is not a number!');
// Check if `args[0]` is a correct amount of time to set slowmode
// Array `validNumbers` are an array consistent of numbers of time you can set slowmode with.
const validNumbers = [
5,10,15,30,60,120,300,600,900,1800,3600,7200,21600,];
// Check if `args[0]` parsed into an interger is included in `validNumbers`
if (!validNumbers.includes(parseInt(args[0])))
return message.channel.send('Invalid Number! Number must be below 21600.');
// Set the slowmode
message.channel.setRateLimitPerUser(args[0]);
// Send the reply
message.channel.send(`Slowmode Set to **${args[0]}**`);
}
});
client.login('');
但是我得到如下错误:
SELECT *
FROM lighting
WHERE cast("time" as timestamp) BETWEEN '23:55:00'::timestamp
AND Now();
我的“时间”列以文本格式如下
ERROR: column "23:55:00::timestamp" does not exist LINE 3: WHERE cast("time" as timestamp) BETWEEN "23:55:00::timestam...
我在做什么错了?
解决方法
似乎您的“时间”字段的值为time
,无法转换为timestamp
。
所以尝试这种方式:
SELECT *
FROM lighting
WHERE cast("time" as time) BETWEEN '23:55:00'::time
AND current_time;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。