Lotus Notes data saved as text field convert to date/time - lotus-notes

Old form that will be replaced by a New, and add a new view.
Old form has:
Expiration Date = Text field
New form:
Expiration Date = Date/Time field
View contains Exp. Date and Days Left.
Problem is Expiration Date of existing data is saved as a Text field. Days Left column read the Exp. Date as a text instead of Date/Time field.
So the Days Left column's output is:
ERROR: Incorrect data type for operator or #Function
Is there a way to convert all the existing date's field to date/time instead of text so the Days Left column's info will be correct? except to re-input the dates manually because the data are too many.

Just create a formula agent with one line of code:
FIELD ExpirationDate := #TextToTime( ExpirationDate )
And let it run on all documents that contain fields with the wrong type.
Of course you could do some error handling in your code as well as:
_newVal := #TextToTime( ExpirationDate );
FIELD ExpirationDate := #If( #IsError( _newVal ); SomeFallbackValue ; _newVal )

Related

how to store double colon values in oracle database table

I have excel which i am trying to import in oracle database table.
Some of the values in excel consist of for example 14:39.5 with double colon. What dataype in oracle database table i should provide to store this value ?
Currently have given varchar datatype and its throwing an error during import as :
Conversion error! Value: "00:12:01.615518000" to data type: "Number". Row ignored! Value is '00:12:01.615518000'. Cannot be converted to a decimal number object. Valid format: 'Unformatted'
You can store it as an INTERVAL DAY(0) TO SECOND(9) data type:
CREATE TABLE table_name (
time INTERVAL DAY(0) TO SECOND(9)
);
Then you can use TO_DSINTERVAL passing your value with '0 ' prepended to the start:
INSERT INTO table_name (time)
VALUES ( TO_DSINTERVAL('0 ' || '00:12:01.615518000') );
db<>fiddle here
If it is part of a date/time stamp then you could store it as DATE or TIMESTAMP if you could add the date component. Oracle doesn't have just a TIME data type.
If you can't add a date component to it, then assuming it is a time interval you could convert it to seconds or microseconds (lose the colons) and store it as a NUMBER.
If you want to maintain the exact formatting as shown, your only option is to store it as text using VARCHAR2 or something similar.

KDB: How to match string of possible dates with rows of table?

I essentially just want to create a date column that represents the date of the filename.
My table filesInDir is just a single column and 4 rows called filepath:
":..\..\code\products\Q\ExtData\CIBC\availability\Global\EquityOnly\daily\bnyMellon_inventory\push_list_20190314_040253_Equity.csv"
":..\..\code\products\Q\ExtData\CIBC\availability\Global\EquityOnly\daily\bnyMellon_inventory\push_list_20190314_040306_Equity.csv"
":..\..\code\products\Q\ExtData\CIBC\availability\Global\EquityOnly\daily\bnyMellon_inventory\push_list_20190311_040321_Bond.csv"
":..\..\code\products\Q\ExtData\CIBC\availability\Global\EquityOnly\daily\bnyMellon_inventory\push_list_20190312_999999_Cash.csv"
I also have a list of possible dates, 2019.03.12 2019.03.11 2019.03.14. How can match the list of dates with the rows of the table above so that I can get a new column that specifies that date value that matched with the filepath string.
If all your file paths follow the same format as your example ones,you can create a date column pretty easily doing:
update date:"D"$8#'103_'filePaths from filesInDir
Then match with your dates using this column.
This is how you parse the filePath to get the date, Please note as "\" is the escape sign so you need to write as "\\" instead that or directly retrieve the string from system command.
Created table
filesInDir:([]filePaths:(":..\\..\\code\\products\\Q\\ExtData\\CIBC\\availability\\Global\\EquityOnly\\daily\\bnyMellon_inventory\\push_list_20190314_040253_Equity.csv";
":..\\..\\code\\products\\Q\\ExtData\\CIBC\\availability\\Global\\EquityOnly\\daily\\bnyMellon_inventory\\push_list_20190314_040306_Equity.csv";
":..\\..\\code\\products\\Q\\ExtData\\CIBC\\availability\\Global\\EquityOnly\\daily\\bnyMellon_inventory\\push_list_20190311_040321_Bond.csv";
":..\\..\\code\\products\\Q\\ExtData\\CIBC\\availability\\Global\\EquityOnly\\daily\\bnyMellon_inventory\\push_list_20190312_999999_Cash.csv"))
Create the date column
update date:{"D"$("_"vs last "\\" vs x)[2]} each filePaths from `filesInDir
I also have a list of possible dates, 2019.03.12 2019.03.11 2019.03.14. How can match the list of dates with the rows of the table above so that I can get a new column that specifies that date value that matched with the filepath string.
Can you give some example illustration on that? Not clear about what you intend and expect to see
If you just want let say a "Flag" column indicating whether the date in the records match with the dateRange, you can simply use a in to match that.
dateRange:2019.03.12 2019.03.11 2019.03.14
update match:date in dateRange from `filesInDir
This will be the output:
Another approach using 0:
update date:raze(" D";"_")0:filePaths from filesInDir
It is dependent on the occurrences of _ in your filepaths

Populating text in report on promotional pricing if PO date falls in offer period

I need to populate a textfield in PO report with a plain text "Promotional" if PO Order Date falls between the Promotional Pricing period (Between Effective and Expiration dates, both inclusive).
For Example,
Promotional Pricing is
$0.50 between 8/16/2017 to 8/31/2017 and,
$9.30 between 9/4/2017 to 9/8/2017
PO Order is
Dated 8/23/2017 then text will NOT be printed
Dated 8/17/2017 then text will be printed
Dated 9/3/2017 then text will NOT be printed
Dated 9/6/2017 then text will be printed
I have included APVendorPrice table and joined with POLine on VendorID and InventoryID. I have Filtered with IsPromotional=1.
However, report considers only the first record of that particular Inventory while printing the text. Below is the code for printing text field.
=IIf(([POOrder.OrderDate] >= [APVendorPrice.EffectiveDate] And [POOrder.OrderDate] <= [APVendorPrice.ExpirationDate]), Trim('PROMO ' + [APVendorPrice.EffectiveDate] + ' ' + [APVendorPrice.ExpirationDate]),'')
Ideally, it should check for all the Promotional Pricing table for that particular inventory and print the text accordingly.
Please suggest.
Answer: Left Join POLine and APVendorPrice tables with InventoryID, VendorID and OrderDate GreaterOrEqual to EffectiveDate and OrderDate LessOrEqual to ExpirationDate. Add IsPromotional condition in visible expression of the textbox.

how to get documents through getAllEntriesByKey with start date ,end date and one text field (e.g Name)

I have a computed field in which I am displaying total number of documents in a view that meet the criteria. I am using GetAllEntriesByKey and want to pass start date, end date and a name field value as search key string. is there a efficient method to get the result.
Create a view with
first sorted/categorized column with date
second sorted/categorized column with name
Get the entries with
var v:NotesView = database.getView("yourView");
var query = new java.util.Vector();
var startDate:Date = new Date(2017,1,1);
var endDate:Date = new Date(2017,2,31);
var range:NotesDateRange = session.createDateRange(startDate, endDate);
query.addElement(range);
query.addElement("searchName");
var vec:NotesViewEntryCollection = v.getAllEntriesByKey(query, true);
(Note for second parameter in Date(): January is 0, February is 1, and so on.)
You could make the first three columns of the view all sorted columns (start date, end date, name).
The Keys parameter for GetAllEntriesByKey can be an array (Vector in Java)
Set the keys array to have the first entry as the start date, second as end date, third as name.

Excel Power Query - from web with dynamic worksheet cell value

We have a spreadsheet that gets updated monthly, which queries some data from our server.
The query url looks like this:
http://example.com/?2016-01-31
The returned data is in a json format, like below:
{"CID":"1160","date":"2016-01-31","rate":{"USD":1.22}}
We only need the value of 1.22 from the above and I can get that inserted into the worksheet with no problem.
My questions:
1. How to use a cell value [contain the date] to pass the date parameter [2016-01-31] in the query and displays the result in the cell next to it.
2. There's a long list of dates in a column, can this query be filled down automatically per each date?
3. When I load the query result to the worksheet, it always load in pairs. [taking up two cells, one says "Value", the other contains the value which is "1.22" in my case]. Ideally I would only need "1.22", not the title, can this be removed? [Del won't work, will give you a "Column 1" instead, or you have to hide the entire row which will mess up with the layout].
I know this is a lot to ask but I've tried a lot of search and reading in the last few days and I have to say the M language beats me.
Thanks in advance.
Convert your Web.Contents() request into a function:
let
myFunct = ( param as date ) => let
x = Web.Contents(.... & Date.ToText(date) & ....)
in
x
in
myFunct
Reference your data request function from a new query, include any transformations you need (in this case JSON.Document, table expansions, remove extraneous data. Feel free to delete all the extra data here, including columns that just contain the label 'value'.
(assuming your table of domain values already exists) add a custom column like
=Expand(myFunct( [someparameter] ))
edit: got home and got into my bookmarks. Here is a more detailed reference for what you are looking to do: http://datachix.com/2014/05/22/power-query-functions-some-scenarios/
For a table - Add column where you get data and parse JSON
let
tt=#table(
{"date"},{
{"2017-01-01"},
{"2017-01-02"},
{"2017-01-03"}
}),
add_col = Table.AddColumn(tt, "USD", each Json.Document(Web.Contents("http://example.com/?date="&[date]))[rate][USD])
in
add_col
If you need only one value
Json.Document(Web.Contents("http://example.com/?date="&YOUR_DATE_STRING))[rate][USD]

Resources