Java.util.Calendar returning wrong Date object
Example: This was my scenario last night. A server in California has date/time of 'Mon Aug 18'. Current time in Indiana is 'Sun Aug 17'. I use Calendar.getInstance(TimeZone.getTimeZone("America/Indiana/Indianapolis")) to return a Calendar instance. I then call the getTime() method on that instance. It should return a Date object relating to that particular time zone. It will not. It defaults back to the server time. When I print out the Calendar instance everything is good, correct date, correct time,etc. WHY WON'T THE getTime() return the correct java.util.Date???
Following is the output was run today so the dates happened to be the same so focus on the Time. Output includes Server time, new Calendar values, and the Date returned by calendar instance getTime(). See that the Calendar is getting the correct Time.
SERVER DATE=Mon Aug 18 15:52:13 CEST 2003
CALENDAR INSTANCE=java.util.GregorianCalendar[time=1061214732975,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Indiana/Indianapolis",offset=-18000000,dstSavings=0,useDaylight=false,transitions=35,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=1,ERA=1,YEAR=2003,MONTH=7,WEEK_OF_YEAR=34,WEEK_OF_MONTH=4,DAY_OF_MONTH=18,DAY_OF_YEAR=230,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=8,HOUR_OF_DAY=8,MINUTE=52,SECOND=12,MILLISECOND=975,ZONE_OFFSET=-18000000,DST_OFFSET=0]
Date from getTime()=Mon Aug 18 15:52:12 CEST 2003
I got it worked with using DateFormat.parse !
The trick is to instantiate a new Date object as a result
of parsing out of 'localized' date string.
with below code :
Calendar localCal = new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles"));
localCal.set(Calendar.DATE, 25);
localCal.set(Calendar.MONTH, 7);
localCal.set(Calendar.YEAR, 2003);
localCal.set(Calendar.HOUR_OF_DAY,6);
localCal.set(Calendar.MINUTE, 38);
localCal.set(Calendar.SECOND, 11);
Calendar sinCal = new GregorianCalendar(TimeZone.getTimeZone("Asia/Singapore"));
sinCal.setTimeInMillis(localCal.getTimeInMillis());
int date = sinCal.get(Calendar.DATE);
int month = sinCal.get(Calendar.MONTH);
int year = sinCal.get(Calendar.YEAR);
int hour = sinCal.get(Calendar.HOUR_OF_DAY);
int min = sinCal.get(Calendar.MINUTE);
int sec = sinCal.get(Calendar.SECOND);
String sinTimeString = date + "/" + month + "/" + year + " " + hour + ":" + min + ":" + sec;
System.out.println("VIDSUtil.hostToLocalTime : time string now in SIN time : " + sinTimeString);
java.util.Date sinTime = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(sinTimeString);
System.out.println("time in SIN using Date.toString(): " + sinTime.toString());
It prints out :
VIDSUtil.hostToLocalTime : time string now in SIN time : 25/7/2003 21:38:11
time in SIN using Date.toString(): Fri Jul 25 21:38:11 PDT 2003
(Ignore the PDT, because Date.toString() defaults where the JVM is running)
Similar Messages
-
Java.util.Calendar calculates wrong date when any duration is added
Hi friends,
I am trying to calculate the date through java.util.Calendar object and getting wrong value. Let me explain the scenario -
Scenario1:
I have taken start date and added some duration to that and expecting a new date which should be calculated as (start date+ duration). The value is as below -
start date = 2012-01-09 (9 January 2012 )
duration = 1year, 1month, 20 days
new date = 2013-02-28 ( 28 February 2013)
*Here new date I am expecting is 2013-03-01 (1 March 2013).
Scenario2:
I have taken another set of values as below -
start date = 2011-02-15 (15 February 2011)
duration = 1year, 1month, 15days
new date = 2012-03-30 (30 March 2012)
*Here new date is as expected.
Scenario1 data is giving me wrong result. Please let me know if any more information is required. Any help will be appriciated. Thanks in advance.
Edited by: user560316 on ९ जनवरी, २०१२ ६:२३ अपराह्न
Edited by: user560316 on ९ जनवरी, २०१२ ६:२४ अपराह्नIt all looks pretty straightforward to me. Try running the following code:
public class TestCalendar {
public static void main(String[] args) {
java.util.Calendar myDate = java.util.Calendar.getInstance();
java.text.DateFormat df = new java.text.SimpleDateFormat("dd MMMM yyyy");
myDate.set(2012, java.util.Calendar.JANUARY, 9);
System.out.println("Start date = " + df.format(myDate.getTime()));
myDate.add(java.util.Calendar.YEAR, 1);
myDate.add(java.util.Calendar.MONTH, 1);
myDate.add(java.util.Calendar.DAY_OF_MONTH, 20);
System.out.println("End date = " + df.format(myDate.getTime()));
}This gives the following result:
Start date = 09 January 2012
End date = 01 March 2013 -
All I want to do is create a java.sql.Date subclass which has the Date(String) constructor, some checks for values and a few other additional methods and that avoids deprecation warnings/errors.
I am trying to write a wrapper for the java.sql.Date class that would allow a user to create a Date object using the methods:
Date date1 = new Date(2003, 10, 7);ORDate date2 = new Date("2003-10-07");I am creating classes that mimic MySQL (and eventually other databases) column types in order to allow for data checking since MySQL does not force checks or throw errors as, say, Oracle can be set up to do. All the types EXCEPT the Date, Datetime, Timestamp and Time types for MySQL map nicely to and from java.sql.* objects through wrappers of one sort or another.
Unfortunately, java.sql.Date, java.sql.Timestamp, java.sql.Time are not so friendly and very confusing.
One of my problems is that new java.sql.Date(int,int,int); and new java.util.Date(int,int,int); are both deprecated, so if I use them, I get deprecation warnings (errors) on compile.
Example:
public class Date extends java.sql.Date implements RangedColumn {
public static final String RANGE = "FROM '1000-01-01' to '8099-12-31'";
public static final String TYPE = "DATE";
* Minimum date allowed by <strong>MySQL</strong>. NOTE: This is a MySQL
* limitation. Java allows dates from '0000-01-01' while MySQL only supports
* dates from '1000-01-01'.
public static final Date MIN_DATE = new Date(1000 + 1900,1,1);
* Maximum date allowed by <strong>Java</strong>. NOTE: This is a Java limitation, not a MySQL
* limitation. MySQL allows dates up to '9999-12-31' while Java only supports
* dates to '8099-12-31'.
public static final Date MAX_DATE = new Date(8099 + 1900,12,31);
protected int _precision = 0;
private java.sql.Date _date = null;
public Date(int year, int month, int date) {
// Deprecated, so I get deprecation warnings from the next line:
super(year,month,date);
if(! isWithinRange(this))
throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
public Date(String s) {
super(0l);
// Start Cut-and-paste from java.sql.Date.valueOf(String s)
int year;
int month;
int day;
int firstDash;
int secondDash;
if (s == null) throw new java.lang.IllegalArgumentException();
firstDash = s.indexOf('-');
secondDash = s.indexOf('-', firstDash+1);
if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) {
year = Integer.parseInt(s.substring(0, firstDash)) - 1900;
month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1;
day = Integer.parseInt(s.substring(secondDash+1));
} else {
throw new java.lang.IllegalArgumentException();
// End Cut-and-paste from java.sql.Date.valueOf(String s)
// Next three lines are deprecated, causing warnings.
this.setYear(year);
this.setMonth(month);
this.setDate(day);
if(! isWithinRange(this))
throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
public static boolean isWithinRange(Date date) {
if(date.before(MIN_DATE))
return false;
if(date.after(MAX_DATE))
return false;
return true;
public String getRange() { return RANGE; }
public int getPrecision() { return _precision; }
public String getType() { return TYPE; }
}This works well, but it's deprecated. I don't see how I can use a java.util.Calendar object in stead without either essentially re-writing java.sql.Date almost entirely or losing the ability to be able to use java.sql.PreparedStatement.get[set]Date(int pos, java.sql.Date date);
So at this point, I am at a loss.
The deprecation documentation for constructor new Date(int,int,int)says "instead use the constructor Date(long date)", which I can't do unless I do a bunch of expensive String -> [Calendar/Date] -> Milliseconds conversions, and then I can't use "super()", so I'm back to re-writing the class again.
I can't use setters like java.sql.Date.setYear(int) or java.util.setMonth(int) because they are deprecated too: "replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date)". Well GREAT, I can't go from a Date object to a Calendar object, so how am I supposed to use the "Calendar.set(...)" method!?!? From where I'm sitting, this whole Date deprecation thing seems like a step backward not forward, especially in the java.sql.* realm.
To prove my point, the non-deprecated method java.sql.Date.valueOf(String) USES the DEPRECATED constructor java.util.Date(int,int,int).
So, how do I create a java.sql.Date subclass which has the Date(String) constructor that avoids deprecation warnings/errors?
That's all I really want.
HELP!I appreciate your help, but what I was hoping to accomplish was to have two constructors for my java.sql.Date subclass, one that took (int,int,int) and one that took ("yyyy-MM-dd"). From what I gather from your answers, you don't think it's possible. I would have to have a static instantiator method like:public static java.sql.Date createDate (int year, int month, int date) { ... } OR public static java.sql.Date createDate (String dateString) { ... }Is that correct?
If it is, I have to go back to the drawing board since it breaks my constructor paradigm for all of my 20 or so other MySQL column objects and, well, that's not acceptable, so I might just keep my deprecations for now.
-G -
Why not Deprecate java.util.Date and java.util.Calendar
With the introduction of java.time, why did you not flag java.util.Date and java.util.Calendar. These classes have been a bane to every Java developer and should never be used again with the introduction of Java 1.8.
Adding the @Deprecated annotation would only just provide a warning about an old API and recommendation to the developer(s) to no longer use it. Doing so would not break any existing library out there; in fact quite a number of constructors and methods on the Date class have already been flagged deprecated.
The new java.time package is far superior to Date/Calendar. -
Web Service Model transforms dateTime elements to java.util.Calendar
The issue is that my EJB returns a java.util.Date object, the WS that exposes this EJB states in the wsdl that it returns a dateTime element (see attachment). Web Dynpro web-service model, when given the wsdl generates proxies that receive a java.util.Calendar. Later this Calendar object cant be bound to UI elements (e.g. tables) see error below.
Has anybody encountered this problem in the past? Do you have a solution, besides manually transferring the java.util.Calendar objects to java.util.Date object?Hi Valery,
I tried changing my return type in a method in the EJB from java.util.Date to java.sql.Date, the problem that I ran into is that I was not able to expose that method in the web service afterwards. This is a bit strange since java.sql.Date is suppose to be supported as a web service Endpoint. I checked this twice just to make sure. -
Report returns wrong data when run on server
Hi,
I'm runing CRS XI R2 on Windows Server 2003 SP2. When I refresh a report in the Crystal Reports XI Designer, I'm getting correct data. But when I schedule the report to run on the server it returns wrong data. The data is different from what I see when I refresh it from the designer. In the report I have running totals set up to count customers that meet a certain criteria. The report is very large. It take almost 2 hours to refresh.
I was wondering what is causing the difference in running total data between refreshing it on the designer and running it on the server. Is it returning wrong data b/c of it not reading all the records? Should I be making any changes to the server settings? I saw that under pageserver, there are options for setting the 'Minutes Before an Idle Report Job is Closed' and 'Database Records To Read When Previewing Or Refreshing a Report". Do either of those have anything to do with the report returning incorrect data when being scheduled to run on the server?
Thanks,
KimHi Xuandao,
You would need to Use Cell Binding and Trigger concept to accomplish this.
Its simple, however, you would have to work on a trial and error basis to understand this concept as implementing the same is subject to your dashboard and WEBI Design.
Open you LiveOffice.
Insert your WEBI, Now, go to Object Properties of your WEBI, select the second tab that says Prompt, Here, it lists the prompts that you have for your WEBI. This would also enlist your BEx variables as well. Select this BEx variable and click on the button that says Prompt at the bottom of this window. Here, select choose Excel Data Range and click on the cell select button on the right (small button that lets you choose what cell you want to bind this prompt to), Now select a free cell that would not be even populated later on when you run the dashboard say A1 (remember the value that you select). Click on OK and again OK. The WEBI Refreshes and you can see all the prompt values at the cell A1. These are all the possible values stored for your BEx prompt variables (these values are fetched from BW system dynamically).
Now, save this LiveOffice, Go to you dashboard. Connect your dashboard to your Live office. Go to Data-> connections-> Now, select the WEBI and in the right hand pane go to Usage tab, here, Click on Trigger cell button on the right hand side and select A1 in you LiveOffice.
It should work fine.
Let me know.
Rgds,
Sreekul Nair -
JSObject returns wrong date. How can I extract correct date from digital signature?
I'm trying to extract name and date from digital signatures by using JSObject in Excel VBA, but JSObject returns wrong date. Year, month, hour and minute are correct, but only day is incorrect.
Here is my code. I'm using Acrobat 8.1.3.
Please tell me what's wrong with this code and how I can extract correct date from digital signatures.
Public Sub sbTest()
Dim oApp As Acrobat.acroApp
Dim oPDDoc As Acrobat.AcroPDDoc
Dim jso As Object
Dim f As Object
Dim sig As Object
Dim strFileName As String
Set oApp = CreateObject("AcroExch.App")
Set oPDDoc = CreateObject("AcroExch.PDDoc")
strFileName = "C:\Test.pdf"
If (oPDDoc.Open(strFileName)) Then
Set jso = oPDDoc.GetJSObject
Set f = jso.getField("Signature1.0")
Set sig = f.signatureInfo()
Debug.Print sig.Name
Debug.Print sig.Date
End If
Call oPDDoc.Close
Call oApp.Exit
End SubHi
You can use TDMS file format to save the data. I have attached a reference Vi.
On button click you can log the data or remove the case structure and continuous log the complete acquisition data.
Thanks and Regards
Himanshu Goyal
Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
Attachments:
Data Save in File.vi 35 KB -
Convert java.sql.Timestamp to java.util.Calendar?
What's the best way to convert java.sql.Timestamp to java.util.Calendar?
Use Calendar's setTime(Date date) method.
java.sql.Timestamp extends java.util.Date.
-Roy -
Ktoolbar does not recognize "java.util.Calendar"
Hi!
Although http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXRPC4.html says that java.util.Calendar is supported, ktoolbar errors out with
error: Found unknown simple type: java.util.Calendar
What's wrong? WSDL not compatible with Java ME?
any help/hint is very much appreciated,
regards FlorianTo be honest, I am a bit lost.
I am beginning / trying to develop a mobile app using WTK / Java ME which uses a web service; the WSDL is here: http://www.pegel-mainz.de/WSDL/v3.0/iLON100.WSDL
Running ktoolbar's stub generator with a local copy of this file, I get the error above, but with a simple MIDlet which just says "Hi", everything builds and runs fine.
Funny thing, at least for me - or make that "irritating":
There is no "Stub" in the generated files. The one class which at least extends "java.rmi.Remote" is "MainSoapPort", but that is only an interface.
But in all tutorials/docs so far I find these Stub-classes to instantiate the service!
I guess I am doing something fundamentally wrong.
Any advice/hint/help/link?
It's very much appreciated (as I'm lost atm)
regards,
Florian -
How to Include Warnings/Error messages in Return Service Data Object
Hello All,
I am using Jdeveloper 11.1.1.3.0, ADF BC. and want to publish Service-Enabled application modules, specifically I want to publish a custome method in the application module as a web service.
While going through Enable support for Service Interface wizard as explained in developer guide, in step 7 I read this
>
7. To expose service information messages such as warnings and exceptions for a custom method or warnings for process operation methods, select Include Warnings in Return Service Data Object. For example, you might want display an informational message when a method returns the total employee compensation and the total is outside of the desired range.
If Include Warnings is not selected, no informational messages will be returned with the service response. This option is only enabled when the method does not return a view row or a list
of view rows. When the method returns view rows, the underlying view object determines whether the method supports warnings, as described Section 11.2.4, "How to Service-Enable Individual View Objects." The informational messages (and warnings) are reported as part of the return object. JDeveloper generates appropriate wrappers as the return objects, and the wrappers contain the actual method return and the informational messages.
>
I am interested in this part: For example, you might want display an informational message when a method returns the total employee compensation and the total is outside of the desired range.
To do this, I write a method in the application module
public Number getEmpSal(Number empId){
EmployeesViewImpl employeesView1 = this.getEmployeesView1();
//this is the bind variable setter
employeesView1.setEmpId(empId);
employeesView1.executeQuery();
EmployeesViewRowImpl first = (EmployeesViewRowImpl)employeesView1.first();
return first!=null ? first.getSalary() : null;
}and I selected the Include Warnings in Return Service Data Object check box. but how and where can I expose the error or warning message?
Note:
I tried to throw an exception in the method
public Number getEmpSal(Number empId){
EmployeesViewImpl employeesView1 = this.getEmployeesView1();
//this is the bind variable setter
employeesView1.setEmpId(empId);
employeesView1.executeQuery();
EmployeesViewRowImpl first = (EmployeesViewRowImpl)employeesView1.first();
if(first!=null && (first.getSalary()!=null || first.getSalary().compareTo(1000)==1))
throw new JboException("out of range salary");
return first!=null ? first.getSalary() : null;
}and when I test the web service for some employee I get this response:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault>
<faultcode>env:Server</faultcode>
<faultstring>out of range salary</faultstring>
<detail><tns:ServiceErrorMessage xmlns:tns="http://xmlns.oracle.com/adf/svc/errors/" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"><tns:code/><tns:message>out of range salary</tns:message><tns:severity>SEVERITY_ERROR</tns:severity><tns:exceptionClassName>oracle.jbo.JboException</tns:exceptionClassName></tns:ServiceErrorMessage>
</detail>
</env:Fault>
</env:Body>
</env:Envelope>but is this the right approach or there is another place to show error/warning messages?
Edited by: Mohammad Jabr on Apr 16, 2012 1:17 PMThis is fine if you raise exception from your code. It will be raised as a server fault only.
-
Hi ,
How to map javax.xml.datatype.XMLGregorianCalendar to java.util.Calendar so that i can use pass String parameter in YYYY-MM-DD format to my Web service.
I generated the schema classes using Jaxb 2.1.5.
Please give suggestion
Thanks in Advance.toGregorianCalendar().getTime()
-
Java.util.Calendar
Where can i find examples for java.util.Calendar
can someone please tell me ^^
Thanks a lottake a look at
java.util.GregorianCalendar
maybe its this you need ... -
PJC Calendar setDate Wrong date format. Date change failed?
Forms 10.1.2 using forms demos pjc code.
The calendar pjc I added to my form works except I can't initialize it with a date. If I try to initialize a date it always produces 'Wrong date format. Date change failed.' error.
In a post-query trigger, I initialize the calendar's date using:
SET_CUSTOM_PROPERTY('PJC.CALENDAR',1,'setDate',to_char(:lead.date_received,'DD.MM.YYYY'));
In the java console, this yields:
Warning: Wrong date format. Date change failed.
Warning: Wrong date format. Date change failed.
I get the same result when using a hardcoded date like:
SET_CUSTOM_PROPERTY('PJC.CALENDAR',1,'setDate','01.12.2006');
What is the flaw in my incantation?Hello,
This is the syntax used in the calendarpjc Forms demo:
call the setDate method on the calendar PJC via the PL/SQL built in
set_custom_item_property
convert Oracle date to String recognised by Java
procedure setDate(d in date) is
begin
set_custom_property(lGlobals.hCalendar,1,'setDate',to_char(d,'Mon DD, YYYY'));
end; Francois -
Function sometimes return wrong data
Hi all.
I have a very strange problem with a function. Situation is this: I have an application that handles processes. Each process have a number of steps that is arranged in a matrix like layout. User clicks a step to start/execute it.
Now in a list of current processes i want to have an indication of how "far" a process has reached so i created a function for that and included that in my processlist fetch.
gchs_user_process_steps is the table where the user data for the process step is
gchs_process_steps is the definition table of what steps a process has
gchs_steps is the definition table of all steps
The below function is supposed to return latest step user clicked in the display matrix. tier is used to store the column number and sortorder is the row number of any step user clicked.
CREATE OR REPLACE FUNCTION FN_REACHEDSTEP(p_user_process_id NUMBER)
RETURN VARCHAR IS
ret VARCHAR(30);
ret_id INTEGER;
ret_num INTEGER;
BEGIN
ret := '';
ret_id := 0;
ret_num := 0;
BEGIN
SELECT substr(step_name,1,30),step_id,reached INTO ret,ret_id,ret_num
FROM (
SELECT a.*, rownum rnum
FROM (
SELECT s.name AS step_name, ps.id AS step_id, max((ps.tier*1000)+ps.sortorder) AS reached
FROM gchs_user_process_steps ups, gchs_process_steps ps, gchs_steps s
WHERE ups.gchs_process_step_id=ps.id AND
ps.gchs_step_id=s.id AND
ups.gchs_user_process_id=p_user_process_id
GROUP BY s.name,ps.id
ORDER BY 3 DESC) a
WHERE rownum <= 1 )
WHERE rnum >= 1;
EXCEPTION
WHEN OTHERS THEN
ret:='';
END;
RETURN ret;
EXCEPTION
WHEN OTHERS THEN
ret := '';
RETURN ret;
END FN_REACHEDSTEP;
Now the problem is that the function sometimes return wrong value. The name of the step that is returned is not the one i get if i run the SQL by itself.
So doing a
SELECT substr(step_name,1,30),step_id,reached INTO ret,ret_id,ret_num
FROM (
SELECT a.*, rownum rnum
FROM (
SELECT s.name AS step_name, ps.id AS step_id, max((ps.tier*1000)+ps.sortorder) AS reached
FROM gchs_user_process_steps ups, gchs_process_steps ps, gchs_steps s
WHERE ups.gchs_process_step_id=ps.id AND
ps.gchs_step_id=s.id AND
ups.gchs_user_process_id=21680
GROUP BY s.name,ps.id
ORDER BY 3 DESC) a
WHERE rownum <= 1 )
WHERE rnum >= 1;
and a
select fn_ReachedStep(21680) from dual;
will sometimes return different values.
So is the function fundamentally wrong or is there any cache or something that i've missed that could hold "old" function outputs or am i missing something else.
Thankful for any clues.
I'm using Oracle 10.2.0.1.0
Best regards
/Tomas
Edit: Here's some data that the system uses.
gchs_steps
ID NAME
10000 Step 1
10020 Step 2
10021 Step 3
10022 Step 4
10023 Step 5
10060 Step 6
10140 Step 7
gchs_process_steps
ID GCHS_STEP_ID TIER SORTORDER
10000 10000 0 1
10001 10020 1 1
10002 10021 1 2
10003 10022 2 1
10020 10023 3 5
10060 10060 3 4
10080 10140 3 2
10040 10040 3 3
10100 10160 4 3
10160 10220 4 2
11640 11640 3 1
11660 11660 0 6
11661 11661 0 7
11600 11600 0 4
11620 11620 4 1
gchs_user_process_steps
ID GCHS_USER_PROCESS_ID GCHS_PROCESS_STEP_ID
35541 21680 10002
38441 21680 10020
38440 21680 10000
52062 21680 10060
Relations beween table is
gchs_user_process_steps.gchs_process_step_id=gchs_process_steps.id
and
gchs_process_steps.gchs_step_id=gchs_steps.id
So doing the SQL alone will always return
SUBSTR(..) STEP_ID REACHED
Step 5 10020 3005
but executing the function sometimes returns
FN_REACHEDSTEP(21680)
Step 6
Also removing the rownum limits return and doing a
SELECT s.name AS step_name, ps.id AS step_id, max((ps.tier*1000)+ps.sortorder) AS reached
FROM gchs_user_process_steps ups, gchs_process_steps ps, gchs_steps s
WHERE ups.gchs_process_step_id=ps.id AND
ps.gchs_step_id=s.id AND
ups.gchs_user_process_id=21680
GROUP BY s.name,ps.id,ps.tier, ps.sortorder
ORDER BY 3 DESC
give this result
STEP_NAME STEP_ID REACHED
Step 5 10020 3005
Step 6 10060 3004
Step 3 10002 1002
Step 1 10000 1
Edited by: user4935832 on 2008-sep-19 01:38ORDER BY 3 DESC) a
WHERE rownum <= 1 )
WHERE rnum >= 1;Just some thoughts.
1. You could replace "ORDER BY 3" by "ORDER BY reached"
2. the rownum <=1 and rnum>=1 will return only one row... I don't understand the second one.
Lastly, the difference might come from a duplicate value return by your MAX() function.
If there is two rows (or more) with same MAX, Oracle might return one row arbitrary.
To get the same row, you have to use some aggregation function like MAX() KEEP (DENSE_RANK LAST...).
Here a try for your query, obviously not tested :
SELECT max(substr(step_name,1,30)) keep (dense_rank last order by reached) as step_name,
max(step_id) keep (dense_rank last order by reached,step_name) as step_id,
max(reached) as reached
FROM (SELECT s.name AS step_name,
ps.id AS step_id,
max((ps.tier*1000)+ps.sortorder) AS reached
FROM gchs_user_process_steps ups,
gchs_process_steps ps,
gchs_steps s
WHERE ups.gchs_process_step_id=ps.id
AND ps.gchs_step_id=s.id
AND ups.gchs_user_process_id=21680
GROUP BY s.name,ps.id) a;Nicolas. -
Date Picker Calendar Show Wrong Date Information Dec/Jan 2014-2015
When using a Date Picker, the offered Date for January 1st 2015 is a Friday! It supposed to be a Thursday!
You can move to February, and return to January again, and it will correct itself.
This happens in Office 2007 and 2010
What's gone wrong?
IT will also offer the wrong December dates.
Is there a fix please?Re: Bad date
Some remote possibilities...
Your computer's clock has an incorrect date
The wrong year is entered somewhere as the first day in 2016 is a friday.
You have the wrong date system selected 1900 vs. 1904 or vice versa.
You have a 3rd party (non MS) Date Picker that is programmed incorrectly.
You have Office 2013 (nothing seems to work there)
There are alternatives and I offer one for Excel...
a free excel add-in date picker ("Get Your Own Date")
(no ads, no trackers, no cookies, no registration)
https://jumpshare.com/b/O5FC6LaBQ6U3UPXjOmX2
Jim Cone
Portland, Oregon USA
Maybe you are looking for
-
hi, i have an ancient ipod and thinkin of getiin a new ipod nano for christmas, da only prob is i have a new pc and all my old music is only on my ipod and not on hard drive, if i get new ipod is there any way i can transfer all my music thats on my
-
Hello everyone, I'm on a Mac OSX 10.8.5 and I am trying to follow these instructions: AMS Financial Aid Forms by Rachael Arestad on Prezi using Adobe Reader 11.0.10. However, there are a couple problems that come up. 1) I can't print the PDF as a PDF
-
Photoshop CS5 printer functions unavailable on new 21" imac, OS X version 10.6.4
Epson Stylus Photo 2200 printer, with the newest driver will not allow me to perform several important functions in Photoshop CS5 These functions are available to me in Photoshop CS2 on a G4 laptop. When photoshop (as opposed to the printer) is assig
-
Problem using claf_classification_of_objects
hi frns, i'm a new abaper and i need some help in utilising this function module claf_classification_of_objects and give me a part of code as an example. thanx, suresh
-
How to delete cache on safari 7
How do you delete the cache only on Safari 7? Don't want to delete the cookies etc. but we used to be able to do the cache alone and now cannot find where or how to do this. Thanks.