Cognos date prompt for specific hours not working as expected - db2

I'm trying to create a report with date prompt. I need a result with 11AM to 11AM data; the query I have written is;
((date(lastupdatetime) = (#prompt('Parameter1')#) and HOUR(Cast(lastupdatetime as TimeStamp))>=11)
or (date(lastupdatetime) = (#prompt('Parameter2')#) and HOUR(Cast(lastupdatetime as TimeStamp))<= 11))
But is is returning whole day data. Can anyone help me out?

The following example will return a 24 hour period starting at 11AM from a user prompted date.
[Date] between #
prompt('FromDate','date')+' 11:00:00.000-05:00'
#
and
#
_add_hours(prompt('FromDate','date')+' 11:00:00.000-05:00',24)
#

Related

Get date of a candle

Im trying to get the date of the last candle, but at the moment i get only the current date.
What im looking for is this data:
Year => 2022
Month => December
Day => 24
At this moment i get this values using:
year(timenow)
month(timenow)
dayofmonth(timenow)
But what's i would like is getting this value based on last daily candle.
If i use Bareplay, using timenow, the value dont change.
Any suggestion?
Merry Christmas at all ☺️
You should use the time function :
The time function returns the UNIX time of the current bar for the specified timeframe and session or NaN if the time point is out of session.
see : https://www.tradingview.com/pine-script-reference/v5/#fun_time
time(timeframe.period) will return you the time of the actual bar, not the time now.
Then you can use year( ) , month( ) and dayofthemonth( ) to retrieve your values.

How to get a specific date of next month? (Java 8)

With today's date, I should get the 16th date of next month.
For example, on passing 13-12-2021, I should get 16-01-2022.
I need to get the next month 16th day from current date (input date). Examples:
On passing 13-11-2021 should get 16-12-2021.
On passing 14-11-2021 should get 16-12-2021.
On passing 15-11-2021 should get 16-12-2021.
On passing 02-12-2021 should get 16-01-2022.
On passing 03-12-2021 should get 16-01-2022.
On passing 03-01-2022 should get 16-02-2022.
On passing 04-01-2022 should get 16-02-2022.
Any help will be much appreciated. Thanks.
java.time
One of the many strong points of java.time, the modern Java date and time API, is date arithmetic like this.
public static LocalDate nthDayOfFollowingMonth(
int desiredDayOfMonth, LocalDate currentDate) {
return YearMonth.from(currentDate)
.plusMonths(1)
.atDay(desiredDayOfMonth);
}
Try it out with your example date:
System.out.println(nthDayOfFollowingMonth(
16, LocalDate.of(2021, Month.DECEMBER, 13)));
Output:
2022-01-16
We might not have needed to convert to YearMonth and back to LocalDate. Doing so relieves both me and the reader of considering what happens if today’s day of month doesn’t exist in next month — for example if current date is 30 January (there is no 30 February). What one still wants to consider is what happens if you request a day of month tht doesn’t exist next month. For example on 13 January asking for the 30th of next month. We can try that out too:
System.out.println(nthDayOfFollowingMonth(
30, LocalDate.of(2022, Month.JANUARY, 13)));
I find the result very reasonable:
java.time.DateTimeException: Invalid date 'FEBRUARY 30'

setDate not setting date properly inside eval in batch script

--eval "var date = new Date(); date.setDate(date.getDate()-10)"'
pause
new Date() gives me the current date. I'm trying to get 10 days back date,but setDate() not setting the date correctly.I'm doing it through batch script.
I got this 1576031482772 after evaluating date.setDate(date.getDate()-10) .Please help me find a solution.
This is the expected behavior. The signature of setDate is as follows. ref
Parameters
It accepts one parameter, it should be number as a day value.
Return Value
It returns milliseconds between 1 January 1970 00:00:00 UTC and the given date
Solution
You are actually setting the day value of date. So If you want to retrieve the value, just use date.getDate(). Which will be the new date.
For more details, how it works, you can refer MDN.

Timezone issues returning a date object to a Google Sheets spreadsheet

I'm writing a custom function to return financial quotes obtained from Yahoo Finance to a Google Sheets spreadsheet (the built-in GoogleFinance() won't cut it for various reasons), and I'm having problems to return a Date object containing the date and time of the quote. https://developers.google.com/apps-script/guides/sheets/functions says that "Times and dates in Sheets become Date objects in Apps Script. If the spreadsheet and the script use different time zones (a rare problem), the custom function will need to compensate", but it's not clear how.
First of all, the timezone of my browser is "asia/hong_kong", i.e. GMT+0800 (HKT). It turns out that the script somehow knows that, because when I format a Date object built with d = new Date(2016,5,24,0,0,0,0) with d.toString() I get "Wed Jun 24 2016 00:00:00 GMT+0800 (HKT)". This is weird, because SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone() actually returns "America/Los_Angeles", indicating that the server is on the West Coast of the US: so why does the method toString(), which is run on the server side, format the date according to the Hong Kong time? This sounds like a bug to me.
Anyway, the biggest problem I'm having is that when the custom function returns the date object to the spreadsheet, if I format the cell with Format -> Number -> Date time, what I see displayed is "23/06/2016 09:00:00", i.e. the date and time on the US West Coast when the Hong Kong date and time are the ones I specified through the parameters passed to the constructor (corresponding to Wed Jun 24 2016 00:00:00).
Then I tried to build the Date object with new Date(Date.UTC(2016,5,24,0,0,0,0)), but (predictably enough) now the spreadsheet displays "23/06/2016 17:00:00", which is the date and time on the West Coast when the UTC date and time are the ones I specified.
So, how do I get a Date object that, once returned to the spreadsheet, shows exactly the same date and time I used to build it? I tried to change the spreadsheet's timezone to UTC using ss.setSpreadsheetTimeZone("Etc/UTC"), but then unfortunately the script returns the error "You do not have permission to call setSpreadsheetTimeZone"...
This is the kludgy solution I managed to write (but I hope there is a better way):
// hours and minutes contain values obtained from the text quote; the date is in the string variable:
// date_str = "05/24/2016";
var tz = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone(); // this returns the TZ of the server, "America/Los_Angeles"
var ums = Date.parse(date_str+" UTC");
var offset = Date.parse(Utilities.formatDate(new Date(ums), tz, "MM/dd/yyyy HH:mm:ss") + " UTC") - ums; // time in LA - UTC time in ms
var d = new Date(Date.parse(date_str));
d = new Date(Date.UTC(d.getFullYear(),d.getMonth(),d.getDate(),hours,minutes,d.getSeconds())-offset);
return d;

How to get the last day of the current month in DataStage?

I have explored all the functions avialable in the trasformer, but could not found the exact function to get the last day of current month by passing date in same default format i.e. yyyy-mm-dd.Please help me in this regard.
Field("31|28|31|30|31|30|31|31|30|31|30|31", "|", MonthFromDate(InLink.dateVar))
It is more precise to establish the first day of next month then use DateFromDaysSince function to establish the day before. I created an integer(6) stage variable which contained century and month+1 from source link e.g. 201410
DateFromDaysSince(-1, StringToDate(svIHBKPR, "%yyyy%mm") : "%yyyy-%mm-%dd")
There is a transformer function called DaysInMonth.
Example: DaysInMonth(“2017-01-23”)= 31