Which is the right way to set the default value for date prompt on cognos prompt function? - prompt

I have an optional date prompt , on my cognos report. And I want to pass the value into an SQL query, but if I won't give a value I want the macro to take a default value.
I am trying the following format , but it seems that it is not working
Where ypd.ACTIVATION_DATE >=
TO_DATE(#prompt('DateFrom','varchar','2000/01/01')# ,'rrrr-mm-dd'
)
As it seems the query does not recognize the '2000/01/01'as a default value.
Any suggestions

There is a sample in the IBM webpage. Reference Link: https://www.ibm.com/support/pages/using-prompt-macro-optional-andor-required.
You only have to add three single quotes at the beginning of the string and three single quotes at the end. I'm using string instead of varchar. Also, please note that the date format should be consistent.
Please try this:
Where ypd.ACTIVATION_DATE >= TO_DATE(#prompt('DateFrom','string','''2000/01/01''')# ,'yyyy/mm/dd' )

Related

Power Automate - Compare StartDate to current date?

We are looking to compare the calendar start date with the current date in flow. Currently we are pulling the start date through a filter query like this:
formatDateTime('EventDate','M-d-yyy hh:mm')
and comparing to this:
formatDateTime(addDays(utcNow(),3),'M-d-yyyy hh:mm')
I am getting this error currently: "Unable to process template language expressions in action 'Get_items' inputs at line '1' and column '17987': 'In function 'formatDateTime', the value provided for date time string 'EventDate' was not valid. The datetime string must match ISO 8601 format."
Any help on this would be greatly appreciated!
You could Initialize a variable like the following below and then do a IF condition.
#{add(div(sub(ticks(utcNow()),ticks('1900-01-01')),864000000000),2)}
I test with the same formula to convert event start date and it works fine in my end. The if condition returns correct result on different conditions.
Here is the logic of my demo flow, please have a check:
I use get item to get the start date of a certain event in the calendar list and convert the start time dynamic content to the format I need. Almost same with yours.
According to the error message, it seems the format of the event date column is not in the supported format. Would you like to provide the settings of your event date column? I test with the default start time column and a custom date & time column of default settings. Both of them works fine with the flow above.
Update:
The two formulas used are displayed below:
formatDateTime(outputs('Get_item')?['body/Event_x0020_Date'],'M-d-yyy hh:mm')
formatDateTime(addDays(utcNow(),3),'M-d-yyyy hh:mm')
I just directly use the outputs of the data compose action in the if condition
What worked for me was to build a sequence of numbers with the dates being ordered by day, month and year this way, when converting to integer, it's easy to compare
int(formatDateTime(utcNow()),'yyyyMMdd'))
if you need add day for exemple, you can use
int(formatDateTime(addDays(utcNow(),variables('extraDays')),'yyyyMMdd'))
and the other date like this
int(formatDateTime(variables('FinalDate'),'yyyyMMdd'))
Based on your example, you can put hours and minutes without any problems, just remove the special characters and spaces
but by the definition of the error you are having, I believe it is because of the way you are writing the variable

Python cx_oracle conversion from varchar2 to date - Error "sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) ORA-01861"

Reading from Oracle database using python sqlalchemy - for a "Date" field stored as "varchar2" in the source .
Sample : Test_col format in Oracle "2019-12-20". This is stored as varchar2 in the source DB.
FYI: Converting "varchar2 to date" in python:
var_1: datetime.strptime('2019-12-20','%Y-%m-%d').date()
Passing var_1 to below sql which finally looks like below:
select *
FROM stg_test_table
WHERE to_date(Test_col,'YYYY-MM-DD') = '2019-12-20'
This is running fine if i run from Oracle developer but running same from Python code, gives below error:
sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError)
ORA-01861: literal does not match format string
Tried multiple date combinations but none of them seems to be working while running from Python.
Can this be linked to cx_oracle version issue?
That's what happens when dates are stored as strings. Although most "dates" have correct format, the one you predicted: YYYY-MM-DD, not all of them do.
For example, if someone entered today's date as 08042020 and you applied the mentioned format mask, you'd get
SQL> select to_date('08042020', 'yyyy-mm-dd') from dual;
select to_date('08042020', 'yyyy-mm-dd') from dual
*
ERROR at line 1:
ORA-01861: literal does not match format string
SQL>
What to do? Expect (a lot?) of pain to fix data. Hopefully, it'll taught you (and the others involved in this) to store dates into DATE columns.
You could, for example, "intercept" invalid formats by using regular expressions (expecting 4 digits - 2 digits - 2 digits), but it won't help with values as 2020-34-87 because it fits the format, but is nonsense.
Or, you could loop through those values (which is row-by-row meaning slow-by-slow) and discard values for which TO_DATE fails.
You could try different format masks, e.g. YYYYMMDD, but - as of 20200408, what is 04 and what is 08? Both can be days or months.
As I said, there's no easy way out of it.
ok so i was able to resolve this, key thing here is to pass the format your DB is expecting, you can check this by:
select value from v$nls_parameters where parameter = 'NLS_DATE_FORMAT';
Considering you are passing correct format, covert using usual TO_DATE conversions and this should work.

Can someone help me with Exception occurred calling method NotesDatabase.FTSearch(string)

I'm trying to do a database full text search and struggling to get it to work.
Since I'm working with date fields, I deleted my full text index, set all my blank date fields to a fictitious date (3/15/2050), compacted the db and then rebuilt the full text index.
However, I am still getting the error for this query string:
(FIELD Form CONTAINS 'Opp') AND (FIELD Topic CONTAINS 'A') AND (FIELD DateTeam >= 3/1/2019) AND (FIELD DateTeam <= 3/31/2019)
I didn't have the single quotes in there initially, but tried it as a suggestion from another post. I also tried putting # before and after my dates, but no luck there either.
What am I missing? My customer is getting frustrated.
You didn't post the verbiage in the exception, nor say what Domino version you were using, so this is somewhat guesswork.
It could be that the UNK table (Domino's internal field catalog) thinks the field is a string field. The first value stored in a field is the type that the FT index uses to determine the indexed data type. Of course any type can be stored in the NSF data but the FT code tries to limit this type of search to fields it believes will work.
Now if those CONTAINS values are actually = values, then DQL can help you. We'll be putting CONTAINS as a verb into DQL in V11, but it (DQL) can certainly perform your date range term. Just a thought.
-John Curtis
This might help: https://www-10.lotus.com/ldd/dominowiki.nsf/dx/full-text-syntax
As far as I know date values must be in [] to work.
A good start is to test your formula in the client with the FT search function instead of altering your code.
By the way: you can shorten your formula omitting the FIELD keyword and putting the field name also in [].
I tried this in my mail database:
(FIELD Form CONTAINS "Memo") AND (FIELD Subject CONTAINS "the") AND (FIELD PostedDate >= 3/1/2019) AND (FIELD PostedDate <= 30/6/2019)
And it works correctly. So double quotes instead of single, and you might have to check whether your date format corresponds with the server's.
The approach I was taking was correct. The problem, however, was that my update agent to set all the date fields had a typo in it so it wasn't setting the right fieldnames to dates. My oversight. Once I found that and corrected it, I retraced my steps and it all works as intended now. Thank you to all for helping me find the solution.
For anyone else, I took these steps:
Open database properties and delete the full text index
Run this command on the console to compact the db: lo compact folder/db.nsf -c
Run an agent against all the docs to set the date fields to a fictitious date
Open database properties again and create a new full text index
When completed, run this command on the console: load updall -f folder/db.nsf
Run the agent again to reset the fictitious dates to blanks

How to extract numeric value instead of text from GuiTableControl?

I use Excel VBA to automate tasks in SAP.
Many times when dealing with GuiTableControl​ the numbers and dates are formatted as text, not values. That causes problems when users have different settings (commas and points as decimal separator, for example).
Is there a function like getcellvalue in GuiGridView?
A workaround would be to access the User Profile in System/User Profile/Own Data/Defaults to get the default format for the current user, and create a function to convert the text to a value depending on the default format.
Try declaring a variable and using the "text" property of the field from the script. For example:
myVariable = session.findById("wnd[0]/usr/tabs_blah_blah").Text
Then use the variable in Excel to populate the formulae to convert in the correct way.

excel datasource returning nulls with sql command

I'm reading excel sheet that has a column formated as number but every now and then contains letters. These are returned as NULLS. I need the values. I added IMEX=1 and that did not help. Changing Values in the registry is not an option. the columns are fixed so is there a way to manually set them to string?
I also tried changing it from advance editor and they go back to the default that is double float.
I am getting the data with an SQL command. Is there a way to force the column to be a type with cast or convert from here? I tried with cast and I keep getting an error.
Try reading in the columns as varchar, then either use a data conversion or derived column transformation within the SSIS package, or update the data once read into the db using cast or convert.
I have found out that cast and convert does not work in this context. I used CSTR(). I was getting error displaying this cell in the preview but the end product was good.

Resources