从SQL的时间戳获取周数
我有一个字段,该字段显示时间戳'mm/dd/yyyy hh:mi:ss'
。我试图从该字段中提取ISOWEEK数字,但根据我使用的公式,未能接收错误消息的变体。
嗨,我希望有人可以提供帮助。
我试图从时间戳获得Isoweeknumber。我尝试了以下3个修订,获取不同的错误消息。
to_char(to_date(Datestamp, 'dd/mm/yyyy'), 'iw')
to_char(trunc(Datestamp),'iw')
to_char(trunc(to_date(Datestamp),'iw'), 'dd/mm/yyyy hh24:mi:ss')
我还反转了to_char(to_date(())
没有运气。
I have a field which displays a timestamp 'mm/dd/yyyy hh:mi:ss'
. I am trying to extract the Isoweek number from this field unsuccessfully receiving a variant of error messages depending on the formula I have used.
Hi, I hope someone can assist.
I am attempting to get the IsoWeeknumber from a Timestamp. I have tried the below 3 revisions getting varying error messages.
to_char(to_date(Datestamp, 'dd/mm/yyyy'), 'iw')
to_char(trunc(Datestamp),'iw')
to_char(trunc(to_date(Datestamp),'iw'), 'dd/mm/yyyy hh24:mi:ss')
I have also reversed to_char(to_date(())
with no luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用与字符串相同的格式(使用
HH24
用于24小时时钟,而不是HH
或HH12
,用于12小时时钟):db<> fiddle
Use the same format as the string (with
HH24
for a 24-hour clock, rather thanHH
orHH12
which are for 12-hour clocks):db<>fiddle here
这就是您可以从日期开始提取周数的方式
This is how you can extract week number from date
随着您的日期和时间
db&lt;&gt;&gt;
As you have date and time
db<>fiddle here