问题标签 [fiscal]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
39 浏览

sql - 如何计算我的财政年度从 2020 年 12 月 26 日星期六开始的 fisc_day_of_wk?

我在 Redshift 中使用以下查询:

在此处输入图像描述

但我需要在第一行为 fisc_day_of_wk 填充 7,然后为 1、2、3 等等。

0 投票
0 回答
14 浏览

r - 如何使用 ifelse 在 R 数据框 Rstudio 中将财政年度转换为日历年

我有一个已经是财年数据的数据框(年+月,假设当前日历年的每年 7 月 1 日是下一个财年),希望在 R 中转换回日历年+月。

我的原始会计年度数据是“ddd”,类型是 Date()

ddd [1] “2022-11-01” “2022-06-04” “2022-07-04”

我希望使用 ifelse() 函数对其进行转换,并避免使用循环以考虑我将来要实现更大的数据框。如果月份在六月之后,则将会计年度的年份向后移动 12 个月。

eee<- (ifelse(月(ddd)>6, (ddd%m+%months(-12)), ddd))

但它显示

易 [1] 18932 19147 18812。

我猜这些是 1960 年的月份数?!我认为我需要强制数据类型,因为 eee 被显示为错误的数字类型。所以我尝试了 eee<- (ifelse(month(ddd)>6, as.Date(ddd%m+%months(-12)), as.Date(ddd))) ,结果是一样的。

我希望得到“2021-11-01”“2022-06-04”“2021-07-04”谢谢!