Extract year from cognos report expression - cognos

I want to extract current year, last year in report expression field but am not able to get it.
date2timestamp(Today()) and Today()
This works fine to get date
_add_years(date2timestamp(Today()),1) and extract("year",Today())
but this shows error.
I wanted to show 2016, 2015 dynamically in my report as heading of cross-tab node.

If you use layout calculation try
substring(date2string(Today()),1,4)
for current year. And
string2int32(substring(date2string(Today()),1,4)) - 1
for previous year.

for current year:
extract('year', date2timestamp(today()))
for prior year:
extract('year', _add_years(date2timestamp(today()), -1))
This will give you an integer value that you can format using the normal Data Format options in the date item properties, for example to remove the thousands comma if desired.

Make a query with two data items.
For the previous year, one data item will have:
extract (year, _add_years(current_date, -1))
And for the current year:
extract (year, current_date).

Related

Amazon Quicksight Dynamic date filter

so everyday I receive sales data from the previous day. So today November 15 I have data from July 2021 until November 14 2021. What I want is to show this data for the current month by aggregating by day. I use a quicksight visual with a MTD (Month To Date) filter. Everything is fine so far.
The problem is on each first date of the month, I see "No Data" on my visual which is normal since I do not have any data from the current day/month but as I said earlier from the day before.
So what I want to achieve is:
Each 1st of current month: show data from the whole previous month
From 2nd to last day of current month: show data from the current month
Can someone help me please to know how I can achieve this?
I looked for ways to do this and I found dynamic default parameters but this option is not fine with me since I have to fill a username column according to the documentation (https://docs.aws.amazon.com/quicksight/latest/user/parameters-set-up.html) and I have many users so it will be not interesting to list all of them.
You can assign parameters to a group rather than a specific user which is much quicker
There is new functionality which allows you to set today or beginning/ending of month/quater/year as default.
See screenshot:
enter image description here

Excel convert from yyyy-MM-dd'T'HH:mm:ss to MM

I am trying to convert a column from yyyy-MM-dd'T'HH:mm:ss to Months
an actual example is as follows
The reason is, I would like to gather how many calls have been done every month possibly in a graph
use Mid to pull the month number:
=--MID(E2,6,2)
to get the month name we need to parse the string to an actual date:
=TEXT(LEFT(E2,10),"MMMM")
Here you go:
=TEXT(A1,"M")
Will return a number from 1 to 12. If you want the full month written out use "MMMM".

Cognos Query to calculate a run date

So in my Cognos report I have a column 'Last Separation Date'. I want run a query on that column to calculate to all persons currently employed or separated from employment within the last two years. However, this date query should auto run to the day I'm running the report. For example. I run the report today 2/22/2020 and view data for the last two year till 2/22/2018. I login few days later to view the report on 3/1/2020. The report should pull data from 3/1/2018.
Create a filter with the between function using current date and some expression which determines a date two years in the past.
https://www.ibm.com/support/knowledgecenter/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.ca_mdlg.doc/c_sql99_current_date.html#sql99_current_date
_add_years or _add_days might be handy as they take negative numbers.
Using the previous answers suggestions, your detail filter would be similar to
[Last Separation Date] between current_date and _add_years(current_date,-2)

Timestamp line to a excel readable timestamp

I have thousands of timestamps in the form shown:
Sun Jul 02 06:00:02 2017 (GMT-04:00)
With Date, Day, and Time all varying. This is a military time stamp ( ie each day counts up to 24 hours)
I have used the following formula to get just the time. But it's not readable by excel.
=MID($A2,FIND(":",$A2)-2,8)
This results in a value like:
06:00:02
However, this does not help and I have to do much manipulation. I want excel to recognize the date and time so i have a true timeline on my x-axis.
I'd like to get it in the form of
7/2/2017 6:00:02 AM
This way I can have a graph that appears like the following:
Graph Example with desired timeline on x axis
Cheers!!!!
Since the weekday and the month are all in three letter abbreviations, you can use the Mid function with an absolute position to extract elements of the date. For just the date you could use
=DATEVALUE(MID(A1,9,2)&"-"&MID(A1,5,3)&"-"&MID(A1,21,4))
For just the time value, you could use
=TIMEVALUE(MID(A1,12,8))
To get the date and time in one value, just add the two and format as you want to see it.
=DATEVALUE(MID(A1,9,2)&"-"&MID(A1,5,3)&"-"&MID(A1,21,4))+TIMEVALUE(MID(A1,12,8))

How to know the current quarter with date?

Is it possible to know the current quarter using Linux command line?
I didn't find a way to do it within the date man page.
The dates corresponding to the start and end of a fiscal quarter vary by country, as well by the nature of the entity doing the fiscal reporting (corporate/personal/government/other...); some companies also have alternate schedules. As such, there is no standard API for this. You will have to get the current month and date and compare it to the appropriate quarter start/end dates for the country and entity of interest. You can find the dates for some countries in wikipedia.
There is now the %q format to show this information.
From the coreutils-8.26 release log from November 30, 2016:
New Features
...
date now accepts the %q format to output the quarter of the year.
And yes it works!
$ date "+%q"
4
$ date "+%Y%q"
20164

Resources