Impala-本月的第一天
我有时间戳格式的可变名称日期。我试图获得一个月的第一天。例如,如果日期为2022-02-27,则我需要的输出是2022-02-01。另一个示例是,如果日期是2022-01-15,那么我需要的输出是2022-01-01,
我需要该月份从该日期字段开始的第一天。我在Impala中这样做,我尝试了几件事,但它没有起作用。
感谢您的帮助!
I have variable name date in a timestamp format. I am trying to get the first day of the month. For example if the date is 2022-02-27 Then the output I need is 2022-02-01. Another example would be if the date is 2022-01-15 Then the output I need is 2022-01-01
I need the first day of that month from that date field. I am doing this in Impala, I tried couple of things, but it did not worked.
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试以下任何一种 -
第一个方法 -
从时间戳列到一个月的第一天截断月份。
第二种方法 -
因此,您从时间戳列中获取Yyyymm,然后将01添加到该字符串中以获取第一天字符串。然后,您可以将其转换为时间戳。
第三种方法 -
类似于第二种方法,但substr用于切割月份。
you can try any one of below -
first method -
truncating Month part from timestamp column to first day of month.
second method -
so, you are getting yyyyMM from your timestamp column, and then add 01 to that string to get first day string. Then you can convert it to timestamp.
third method -
similar to second method but substr is used to cut the month part.