How to find week of the year for the date value? - apache-nifi

My Flow having attribute '05-05-2015'.And i need to find week of the date in NiFi.
For example:
if date is 05 then it is belongs to 1st week of the year.
I shouldn't use Script/Program for find out week.
i need to find out that using NiFi Expression language only.
Can anyone suggest way to do that?

assume eee is your attribute
then expression
${eee:toDate('MM-dd-yyyy'):format('u E')}
output:
2 Tue
format reference:
http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Related

Set analysis Qlik sense - Set analysis - Date beetween last month of last year and current month of the year

i have a column which name "Period" and i have last 18 months ( janvier 2021 to novembre 2022)
In my graph i want show only month december 2021 to novembre 2022. I would like to show months beetwen last month of the year and current month.
Thanks in advance for your help :)
You can use set analysis to achieve this:
Sum(
{<[Period] = {">=$(=AddMonths(YearStart(Today()), -1))<=$(=Today())"}>}
[FieldToSum]
)
This set expression works by using:
Numeric search by using the ">=...<=... syntax
Dollar-sign expansion of dates by using the $(=...) syntax
EDIT: See below screenshot

Is the day of the week for a date the same everywhere in the world?

Part of my program requires checking the day of the week that a file was created. I have an input attribute which gives the date of creation in US form (month/day/year). However I do not have the day of the week.
As per the sadism of the legal department I am also restricted to only the time modules within python's standard library so unfortunately the obvious solution of PYTZ is not an option.
My current approach is to use the date to reference the Gregorian calendar. On the assumption that a the same date is always the same day i.e. 1st September 2022 is a Thursday everywhere in the world. However, I have not been able to validate this assumption.
If you know if this assumption is correct/incorrect and/or know of somewhere I can find out I would be very grateful.
Thanks.

Can i get the 2 hour digits in Oracle Business Intelligence using HOUR()?

I'm trying to get the hour from a timestamp column, i use the HOUR() funtion and im available to get it but i need to get the 2 digit hour.
This is what i already try:
HOUR("Column.Name")
This is what i get in my output, do not worry about the minutes:
For example in my output i have 7:00 and 9:30, after using the HOUR function i would like to get 07 and 09 instead of 7 and 9.
Anyone can help me?
select LPAD(extract(hour from SYSTIMESTAMP),2,'0') from dual;
You can use the Oracle extract functionality which extracts hour from a TIMESTAMP field.
Note : It does not work with DATE datatype only TIMESTAMP should be an input parameter
Oracle Reference : https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions052.htm#SQLRF00639

How to index the document with three letter month format?

Following is the document I have.
{
"host": "172.31.183.9",
"log_sequence": "47280",
"log_date": "Nov 3 12:29:26.096"
}
I have tried the following date formats for mapping
a. dateOptionalTime
b. MMM d HH:mm:ss.SSSZ
but it is still showing mapper parsing exception. Can anybody suggest a way for the mapping format?
The problem is with the Z at the end of your date format, which expects a timezone offset/id, which is missing from your example.
So this pattern MMM d HH:mm:ss.SSS should work.
Elasticsearch official date format documentation says it support custom datetime format under joda.
Joda documentation for datetime mention
M month of year month July; Jul; 07
Month: 3 or over, use text, otherwise use number.
So you can refer this documentation to create a custom format for elasticsearch mappings and index the data accordingly.
I think you can figure out a way if you will play around with custom joda datetime formats.
Post the exact mappings if this helps

How to write a shellscript date check that will not To run Except 3rd week sat, Sunday and 4th week Monday of the month

E.g. the schellscript will not run on april 18, 19 and 20 and then for may is 16, 17 and 18 and so on
You can get the weekday in numerical form from the date command using date "+%w".
The output will be 0 for Sunday, 1 for Monday etc.
You can get the day of the month using date "+%d". Subtract one from that and divide by 7; that will give you how many complete weeks there have been in the current month.
From there, it's just a simple bunch of if/then statements. If you need more help actually implementing this, just ask.
Hope that helps!
I would advise to use cron for this kind of things, to separate the planned execution from what the script really does.
Have a look here on how to use cron.

Resources