Get a particular day from a range of dates using oracle - oracle

I want to get a Monday/any particular day from a range of days. The range of days is always a week.
Example: The week is 12/13/2014 - 12/19/2014. If I want to get a Monday/Tuesday from this range, how do I do that?

You can use function NEXT_DAY, for example:
next_day('12/13/2014','MONDAY')
Give you next Monday.
next_day('12/13/2014','TUESDAY')
Give you next Tuesday.

Related

How to get last day of current month via Ni-Fi expression language?

As far as I understood there's only now() function available in ni-fi expression language to get time. I can easily get 1st day of each month since it is a constant, but how can I get last day of a current month since it varies from month to month?
Thank you beforehand!
${now():format("yyyy-MM-32"):toDate("yyyy-MM-dd"):format("yyyy-MM"):toDate("yyyy-MM"):minus(86400000)}
//^now ^next month ^to date ^1st of next month ^minus 1 day
nifi should provide a function for that...

First Week of Month in Power BI

I have a date table with Day and Date columns in Power BI.
I would like to add a column which tells me if that week includes the first day of month.
For example when 1st of November is Friday, then it returns a "Yes" for that week.
Therefore, the column "IsFirstWeekOfMonth" shows "Yes" for the working days of a week which has 1st day of month.
Something like below:
Would you please let me know how I can do this in Power BI (M or DAX). Many thanks in advance
You can add a calculated column with the following logic, also checking if is or not a weekend day (for Saturdays and Sundays):
IsFistWeekOfMonth = IF(OR(WEEKDAY('Table'[Date].[Date],2)==6,WEEKDAY('Table'[Date].[Date],2)==7),"No",IF(AND(OR(WEEKNUM(DATE('Table'[Date].[Year],'Table'[Date].[MonthNo],1))==WEEKNUM('Table'[Date].[Date],2),WEEKNUM(DATE('Table'[Date].[Year],'Table'[Date].[MonthNo]+1,1))==WEEKNUM('Table'[Date].[Date],2)),WEEKDAY(DATE('Table'[Date].[Year],'Table'[Date].[MonthNo],1),2)IN{1,2,3,4,5}),"Yes","No"))
Please tell me if this can help you.

PowerBi - Show last week (Monday to sunday)

I'm fairly new to powerbi.
I want to be able to use a slicer to show the last week not the last 7 days.
I know you can use de relative week, but that shows the dates from Sunday to Monday.
I've also red that it's not possible to change the slicer settings for this.
Is it possible to archiev this in another way?
This is my date table https://imgur.com/a/dCcfBAZ
You can add a column that calculates last weeks' weeknumber and compares it to the weeknumber of the date in your row. Find the weeknumber for the current datetime (NOW), subtract 1, wrap that in an IF and you get a boolean to slice with:
LastWeek = IF((WEEKNUM(NOW(),2) - 1) = YourTableName[Weeknum],true,false)
Works the same as the relative week slicer option, but with the week starting on Monday.

Get Week Number of the year with custom day as starting day of the week

I want to use Date.WeekOfYear() Function to get Week Number for datetime values, but with a custom day as the start of the week (Let's say Saturday rather than Sunday). How is it possible in PowerQuery M?
You could use a conditional statement like this (adding 1 to the weeknumber if the day is saturday):
if Date.DayOfWeek([Date])=5 then Date.WeekOfYear([Date])+1 else Date.WeekOfYear([Date])

Retrieve data based on current ISO week and backwards

I have to work with data retrieved and grouped on a weekly basis (ISO week) and my DB is structured on a daily basis (field: DATE). I need to write down a code which is rolling, so that given the current date, it calculate the week and the retrieve data in the previous 3 weeks, too.
So I write in the WHERE clauses:
TO_DATE(TO_CHAR(DATE, 'YYYYWW')) BETWEEN TO_DATE(TO_CHAR(TO_DATE(running_date, 'YYYYMMDD'), 'YYYYWW'), 'YYYYWW')-3 AND TO_DATE(TO_CHAR(TO_DATE(running_date, 'YYYYMMDD'), 'YYYYWW'), 'YYYYWW')
It doesn't seems to work though.
Any suggestions on how to handle the problem?
Thanks a lot!
You have to subtract 21 days when you want to recive the previous 3 weeks. If you subtract 3 then you recive only the last three days.
You need to use 'IW', not 'WW' as the format mask for ISO week. From the Oracle docs:
IW = Week of year (1-52 or 1-53) based on the ISO standard.
WW = Week of year (1-53) where week 1 starts on the first day of the year and
continues to the seventh day of the year.

Resources