OBIEE adding an integer to date - obiee

I am looking to add a number of days (column 1- integer) to a date (column 2- date) to create another date in the future (column 3- date).
What is the code required?

Try using this formula for column3
TIMESTAMPADD(SQL_TSI_DAY,CAST("Table"."Column1_int" AS INTEGER), "Table"."Column2_date")

Thanks for giving me a great start. Here is what ended up working:
TimestampAdd(SQL_TSI_DAY,"Customer"."Cycle Days","Customer"."Next Inspection Date")
"Customer"."Cycle Days" - # (integer) of days to be added to the date
"Customer"."Next Inspection Date" - date

Related

Day of Month must be between 1 and last day of month

Trying to write a query where I can see the format of a date using the query below
select to_date((substr(Key ,8,15)),'yyyymmdd') from Myrules
where LENGTH(substr(Key ,8,15)) = 8;
the data looks like this in the Key field
AA-FFL-20200706
AA-FFL-20200961
AZ-MDL-20200961
AZ-MGL-4
I'm getting the error saying "day of month must be between 1 and last day of month" Any idea what am I doing wrong above?
There's no day 61 in any month I know.
AA-FFL-20200961
AZ-MDL-20200961

Next week in Oracle

I'm using oracle dbms and I have in Employe table a column Birthdate. I want to write a query that shows the employees who has a birthday next week.
Is this correct ?
select name
from employe
where to_char(birthdate,'DD-MM')=to_char(next_day(sysdate,1)+7,'DD-MM');
That is not the correct usage of next_day(): that function returns the date of the the next instance of a day. For example, to find the date of next Friday:
select next_day(sysdate, 'FRIDAY') from dual;
To find employees whose birthday is seven days from now, you need to just tweak your query a bit:
select name
from employe
where to_char(birthdate,'DD-MM') = to_char(sysdate+7,'DD-MM');
The correct solution would be
SELECT name
FROM employe
WHERE to_char(birthdate
/* "move" the birthdate to the current year
to get a reliable week number */
+ CAST((EXTRACT(year FROM current_date)
- EXTRACT(year FROM birthdate)) || '-0'
AS INTERVAL YEAR TO MONTH),
'IW')
= to_char(current_date + 7, 'IW');
The IW format returns the ISO week containing the date, which is probably what you are looking for. If you start your week on Sunday, add one to both dates.

Single Month Digit Date Format issue in Oracle

Am getting the below issue when am using 'mon-d-yyyy' to convert date to char, as i need a single day digit for values from 1 to 9 days in a month.
When i use the 'mon-d-yyyy' format, am losing out on 5 days and getting a wrong date. Any help on this would be great.
select to_char(sysdate-22,'mon-d-yyyy') from dual;--aug-2-2017
select to_char(sysdate-22,'mon-dd-yyyy') from dual;--aug-07-2017
select sysdate-22 from dual;--07-AUG-17 11.06.43
In Oracle date formats, d gets the day of week. The 2 in your output means monday, not august the 2nd.
Try using Fill Mode as Format Model Modifier
select to_char(sysdate-22,'mon-fmdd-yyyy') from dual;
One option might be to piece together the date output you want:
SELECT
TO_CHAR(sysdate-22, 'mon-') ||
TRIM(LEADING '0' FROM TO_CHAR(sysdate-22, 'dd-')) ||
TO_CHAR(sysdate-22, 'yyyy')
FROM dual;
The middle term involving TRIM strips off the leading zeroes, if present, from the date.
Output:
Demo here:
Rextester
SQL>SELECT TO_CHAR(TO_DATE('29-AUG-2017','DD-MON-YYYY') - 22,'"WEEKDAY :"D, MON-FMDD-YYYY') "Before22Days" FROM DUAL;
D- Gives you a numeric weekday(2nd weekday in a week) on AUG-07-2017.
DD-Gives a Numeric Month Day i.e,07th
FMDD-Gives 7th
Before22Days
----------------------
WEEKDAY :2, AUG-7-2017

access: compare date with numeric

Please help!
I want to compare two dates is Access, only problem is, one date is nummeric in the table like 20160316 and the other date is as date in table like #20-02-2016#
How can I calculate how many days are between these two dates?
Thnx a lot!
You can use:
Select
*,
DateDiff("d", CDate(Format([NumericDate], "####\/##\/##")), [TrueDate])
From
YourTable1
or, for positive only differences:
Select
*,
Abs(DateDiff("d", CDate(Format([NumericDate], "####\/##\/##")), [TrueDate]))
From
YourTable1

How to calculate Date difference in Hive

I'm a novice. I have a employee table with a column specifying the joining date and I want to retrieve the list of employees who have joined in the last 3 months. I understand we can get the current date using from_unixtime(unix_timestamp()). How do I calculate the datediff? Is there a built in DATEDIFF() function like in MS SQL? please advice!
datediff(to_date(String timestamp), to_date(String timestamp))
For example:
SELECT datediff(to_date('2019-08-03'), to_date('2019-08-01')) <= 2;
If you need the difference in seconds (i.e.: you're comparing dates with timestamps, and not whole days), you can simply convert two date or timestamp strings in the format 'YYYY-MM-DD HH:MM:SS' (or specify your string date format explicitly) using unix_timestamp(), and then subtract them from each other to get the difference in seconds. (And can then divide by 60.0 to get minutes, or by 3600.0 to get hours, etc.)
Example:
UNIX_TIMESTAMP('2017-12-05 10:01:30') - UNIX_TIMESTAMP('2017-12-05 10:00:00') AS time_diff -- This will return 90 (seconds). Unix_timestamp converts string dates into BIGINTs.
More on what you can do with unix_timestamp() here, including how to convert strings with different date formatting: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions
yes datediff is implemented; see:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
By the way I found this by Google-searching "hive datediff", it was the first result ;)
I would try this first
select * from employee where month(current_date)-3 = month(joining_date)

Resources