I am working with an OAF extension in Oracle EBS. We have attribute columns (varchar datatype) provided by Oracle where we can store additional data. We need to store two date fields which are entered by the user.
In the OAF Java page, when user selects the date from the calendar pick and hit save it stores in the format - YYYY-MM-DD in the DB table. eg 2022-05-22
But while being retrieved I need to show that as MM/DD/YYYY to show the dates in alignment in OAF page. The problem here is that next time (2nd time onwards) when we try to save (not by selecting the calendar again as dates are already populated in the view) it's saved in the format MM/DD/YYYY. And there onwards the below view query fails.
select TO_CHAR(TO_DATE(2022-05-22, 'YYYY/MM/DD'),'MM/DD/YYYY') from dual;
Is there a way I can always enforce to store the value as MM/DD/YYYY either in the JAVA code or the PL/SQL Package that's being called. I am basically retrieving the field value in JAVA and invoking the PL/SQL procedure to update it in the table.
DBUtil.setString((OraclePreparedStatement)oracleCallableStatement, b1++, busClassVORowImpl.getAttribute1())
DBUtil.setString((OraclePreparedStatement)oracleCallableStatement, b1++, busClassVORowImpl.getAttribute2())
Related
I have a table with a regid(primary key) and a date column with their values as 12 and 2020-09-23 respectively . If i want to retrieve the date in JSP i can simply do it as ${date}. But after updating this particular regid the date changes. So how will I compare the previous date with the current updated date.
For your use case you will have to maintain one more column for previous date value which will be updated when you save the new date.
Or if you just want to show you temporarily for that request then you can use one Transient variable for setting the previous date value and show that field in JSP.
Trigger
A more powerful database will offer the feature of triggers, code that executes on the database server every time a row is being inserted, updated, or deleted.
That trigger code you write will be able to see both the old and new values of the row being modified. That trigger code can calculate the delta, and write that data to another column or to a row in separate history-keeping table. This kind of history-tracking is a common use of triggers.
Your JSP would need to query that other column, or other table, to get the original value or delta (whichever or both that you decide to store).
Before and after vars
Alternatively, if your JSP is making the change to the database, then obviously it can keep the original value and the new value as objects in memory.
I'm trying to get the user to pick a date and then on click of a button will display all the content from Firestore related to that data.
Here mDisplayDate is a DatePicker Dialog and I want to display the data. I've done the display part but whereEqualTo() takes two hard coded strings as field and value.
noteBookref.whereEqualTo("Date" , mDisplayDate.toString()).orderBy("Date", Query.Direction.DESCENDING).get();
The Database looks like this
I'm trying to filter firestore content on basis on of a date picked by user. Say Display all data for 14th Feb
You are storing the Date property as a String you are doing it wrong.
To be able to query your database according to a specific date, your Date property should be o type Date and not String. To see how you can achieve this, please take a look at my answer from this post.
Once you have the property set correctly, a query like this should do the trick:
noteBookref.whereEqualTo("Date" , date).orderBy("Date", Query.Direction.DESCENDING).get();
In which date is a Date object representing the date you are looking for. Remember to delete the existing data and add fresh one.
I am using bootstrap datetimepicker and using format as YYYY-MM-DDTHH:mm:ssZ the text input I am storing as it is in database column.
I have to store it as string only. While fetching records I am passing fromdate and toDate which are for applications timezone (other than client machine). We set timezone through application as well.
For MySQL query I am doing date comparison using:
str_to_date(column_name,'%Y-%m-%dT%T')
This gives an issue in fetching records. Any suggestions?
My problem is when I am not sure whether I am right about datetimepicker format.
I have to store it as string only.
Stop. Right there. There are very few reasons why you would really want to store your dates and timestamps in a MySQL database as pure text. Instead, you should be using a date column, which would alleviate your need to call STR_TO_DATE in the first place.
With regard to your call to STR_TO_DATE, I think your format mask should be this:
STR_TO_DATE(column_name, '%Y-%m-%dT%H:%i:%sZ')
This appears to be working in the demo below.
Demo
I made a report as of the date of purchase transactions.
I want to display the format as below:
In pictue above the date is only displayed once at the top.
Now, the date shown in each record that appears.
I already have the solution using subreport. In my report i select distinct for the date. And subreport using parameter from primary report.
But the problem now is, the data in each date is duplicate in every row.
How to handle that?
You can use Subreport to do this. Example i will have two sql, the first sql i will call DISTINCT all date and then the second sql (use for subreport) i will get all data have date like date in the first sql (using parameter). (Sorry my English is not good, i can'tardescrip all for you :).)
I'm having some issues with a pre-made Java master table.
The problem is that it requires to show an inserted date from my PHPMyAdmin in the form off dd-mm-yyyy-hh-mm-ss, but instead it only shows dd-mm-yyyy. Only if I edit it in the application itself it shows me the correct form.
I know some methods to format it but I could not figure out how to use these in a premade master table.
Use DateAndTime in Java and in your PhpMyAdmin have you declare a Date and Time or just Date?