Fiscal Week and year from Timestamp??
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 33
- Joined: Sat Jul 02, 2005 2:27 am
- Location: Bangalore
Fiscal Week and year from Timestamp??
Fiscal week starts from first week of February. hence 1st Jan 2006 would be of fiscal week 49 and fiscal year 2005.
Week 1 starts from 1st of January.
I have timestamp as an input field. Here if I am trying to get week from timestamp then what I am getting is week of the year.
I have used the below funtion for the above conversion:
'W': YearweekFromDate(TimestampToDate(time_stamp_field))
'Y': YearFromDate(TimestampToDate(time_stamp_field))
For this if the input is 1st Jan 2006 then the results are W1 and Y2006.
Is there a function which will give me the fiscal year and week from timestamp?
Appreciate your response regarding this.
thanks and regards,
Ajith
Week 1 starts from 1st of January.
I have timestamp as an input field. Here if I am trying to get week from timestamp then what I am getting is week of the year.
I have used the below funtion for the above conversion:
'W': YearweekFromDate(TimestampToDate(time_stamp_field))
'Y': YearFromDate(TimestampToDate(time_stamp_field))
For this if the input is 1st Jan 2006 then the results are W1 and Y2006.
Is there a function which will give me the fiscal year and week from timestamp?
Appreciate your response regarding this.
thanks and regards,
Ajith
Re: Fiscal Week and year from Timestamp??
Since fiscal years vary from country to country, there is no built in function. But it is fairly easy to calculate. For example,
Similarly
Code: Select all
Y: if MonthFromDate(TimestampToDate(time_stamp_field)) < 2 then YearFromDate(TimestampToDate(time_stamp_field)) - 1 else YearFromDate(TimestampToDate(time_stamp_field))
Code: Select all
W: if MonthFromDate(TimestampToDate(time_stamp_field)) >=2 and MonthFromDate(TimestampToDate(time_stamp_field)) <= 12 then YearweekFromDate(TimestampToDate(time_stamp_field)) - YearweekFromDate(YearFromDate(TimestampToDate(time_stamp_field)) : "-01-31") else YearweekFromDate(TimestampToDate(time_stamp_field)) + YearweekFromDate(YearFromDate(TimestampToDate(time_stamp_field)) : "-12-31") - YearweekFromDate(YearFromDate(TimestampToDate(time_stamp_field)) : "-01-31")
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
-
- Participant
- Posts: 33
- Joined: Sat Jul 02, 2005 2:27 am
- Location: Bangalore
-
- Participant
- Posts: 33
- Joined: Sat Jul 02, 2005 2:27 am
- Location: Bangalore
Really?? I googled "ralph kimball time dimension" and the first listed item is his most famous white paper on it? You need to read it to understand your solution is not ETL but architecture. A data warehouse uses a Time dimension to facilitate the calculations you are charged with doing. We've talked about your particular query and similar others for years and my steady answer is always to implement a Time dimension and use it in your calculations. I'm not saying you have to do foreign surrogate key substitution, but for heavens sake at least look up your dates in the table to get the attributes you require.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle