Querying by date field parts: month, year
Hi,
is there ability in JDOQL to get month or year of date field and use them in
filter? Example:
search(Payment.class, "processDate.ext:getYear() == (select
c.createDate.ext:getYear() from Client c where clientID == c.ID)");
thanks,
Povilas
is there ability in JDOQL to get month or year of date field and use them in
filter? Example:
search(Payment.class, "processDate.ext:getYear() == (select
c.createDate.ext:getYear() from Client c where clientID == c.ID)");Unfortunately, there is not. As your example indicates, however, you could code
a custom query extension in Kodo to extract the year from a date in SQL.
Similar Messages
-
Query returns data from previous month. Need to have it return data for the entire year
This is the part of the query that returns data by month:
(YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)AND MONTH(`rereport`.`market_reports_5`.start_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH))
How can I get it to return data for the year.
TIYHow about omitting the MONTH part:
(YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
Concatenate Date fields as month and year
Hi,
I want to concatenate the field bseg-augdt as month and year.
And have to append as a seperate field (Fiscal month | fiscal year) in the output.
Plz help me to overcome this issue.
Thanks and Regards,
Karthik
Moderator message: very basic, please try yourself and search for information before asking.
locked by: Thomas Zloch on Aug 4, 2010 1:22 PMEnv : ORACLE REPORTS 9I
I am passing 3 parameters to the report:
Parameters are of type CHAR
Report Parameters
Year / Month : 2005 / AUG
Effective Date :
The colunm in table is eff_date
eff_date
01/08/2005
02/08/2005
03/08/2005
15/09/2005
17/09/2005
18/09/2005
29/09/2005The problem is:
1)If I dont enter anything,I just get displayed 2 record for the above.
It should display all records rather than 2.
2)If I enter Effective date as 01-AUG-2005,no records are displayed.
This is my code:
Select col1,col2
from TableA
where ( TRUNC(ch.eff_date) = nvl (:E_DATE, TRUNC(ch.eff_date) )
AND TRUNC(ch.eff_date, 'MONTH') = nvl (TO_DATE(:YR||:MTH, 'yyyymon') ,
TRUNC(ch.eff_date) )
)Shud i change the AND to OR? -
SQL Query for Date field updation
I want a query from u.. Hope u help me with a
solution soon..
My Q: I want to update a date field in Oracle
database. But the condition is that i shouldnt change
the hours, minutes & seconds of the date field.
generally , if we update the date field then it takes
the default values for hours, min's & sec's to
00:00:00.
EX : if we have a value 21-SEP-2002 04:54:44 in a date
field. I want to update it to 22-SEP-2002 04:54:44.
But it updates to 22-sep-2002 00:00:00 if we use
UPDATE command.Use a PreparedStatement:
PreparedStatement ps = conn.prepareStatement("SELECT * FROM TEMP WHERE TDATE > ? AND TDATE < ?");
// note: month numbers start at 0, so 1 is february
GregorianCalendar c1 = new GregorianCalendar(2002, 1, 11, 11, 0);
GregorianCalendar c2 = new GregorianCalendar(2002, 1, 18, 22, 0);
Date d1 = c1.getTime();
Date d2 = c2.getTime();
java.sql.Timestamp sqlDate1 = new java.sql.Timestamp(d1.getTime());
java.sql.Timestamp sqlDate2 = new java.sql.Timestamp(d2.getTime());
ps.setTimestamp(1, sqlDate1);
ps.setTimestamp(2, sqlDate2);
ResultSet rs = ps.executeQuery();
// get results from the result setJesper -
Bex Query report error in cal month /year column
Hi Experts,
We have a bex query on virtual provider with only one column in it i.e 'cal year / month'( This virtual provider ahs been created from planning area). I'm having the problem with this column.
In the excel output of this report the cal year /month is displaying as follows.
01/0000 02/0000 03/0000 04/0000 05/0000 06/0000 07/0000 08/0000 09/0000 08/2008 09/2008 10/2008 11/2008 12/2008 01/2009 02/2009 03/2009 04/2009 05/2009 03/2010 04/2010 05/2010 06/2010 07/2010 08/2010 09/2010 10/2010 11/2010 12/2010 01/2011 02/2011 03/2011 04/2011 05/2011 06/2011 07/2011 08/2011 09/2011 10/2011 11/2011 12/2011 01/2012 02/2012 03/2012 04/2012 05/2012 06/2012 07/2012 08/2012
I'm not getting why the first 9 columns its displaying as 01/0000 02/0000 03/0000 04/0000 05/0000 06/0000 07/0000 08/0000 09/0000 .
It should display as
08/2008 09/2008 10/2008 11/2008 12/2008 01/2009 02/2009 03/2009 04/2009 05/2009
06/2009 07/2009 08/2009 09/2009 10/2009 11/2009 12/2009 01/2010 02/2010 03/2010 04/2010 05/2010 06/2010 07/2010 08/2010 09/2010 10/2010 11/2010 12/2010 01/2011 02/2011 03/2011 04/2011 05/2011 06/2011 07/2011 08/2011 09/2011 10/2011 11/2011 12/2011 01/2012 02/2012 03/2012 04/2012 05/2012 06/2012 07/2012 08/2012
My data source is fetching the correct data including this cal year/ month.
Thanks in advance for your help.
Regards,
Brahma ReddyI assume you are running Crystal for enterprise 4.0 SP02 Patch 08 !!
According to OSS note 1651521 , This issue has been fixed in FP3 which is planned to be released in first quarter of 2012 !!!!!! ouch !!!!!
I am facing same issue , Pls let me know if you already solved it.
Regards,
Miraj Desai.
Edited by: Anne Howard on Nov 29, 2011 6:58 AM -
BEX Query: by selection of actual month/year also shows month/year-1
Hi
When I set the selection value 11.2010 or also 11/2010, as result of the Query I get the values for 11.2010 but I also receive 11.2009.
This also when I use the selection with 11/2010, I get also 11/2009 too.
Can someone tell me how I can set the query, that it will stick with my values and not add the previous year?
Thank you very much for your help.
PetraCheck whether the variable created for month year is a customer exit Variable.
In a customer exit variable the code can be written such as to bring the data from current year current month to the last year current month. -
Query for date generating the months as well
Hi Folks
I need your help to resolve th query below
I need to generate the sql query
example
YEAR MONTH count(EMPNO)
1981 JAN 0
FEB 2
MAR
DEC
I need to generate all the months and count of employee being hired for that month,where the month without any emp being hired should show as 0Or perhaps...
SQL> WITH t AS (SELECT TO_DATE('01/01/2008','dd.mm.yyyy') AS dt, 1 AS eno FROM dual UNION ALL
2 SELECT TO_DATE('01/01/2008','dd.mm.yyyy') AS dt, 2 FROM dual UNION ALL
3 SELECT TO_DATE('01/02/2008','dd.mm.yyyy') AS dt, 3 FROM dual UNION ALL
4 SELECT TO_DATE('01/06/2008','dd.mm.yyyy') AS dt, 4 FROM dual UNION ALL
5 SELECT TO_DATE('01/03/2007','dd.mm.yyyy') AS dt, 3 FROM dual UNION ALL
6 SELECT TO_DATE('01/05/2007','dd.mm.yyyy') AS dt, 4 FROM dual UNION ALL
7 SELECT TO_DATE('01/02/2008','dd.mm.yyyy') AS dt, 5 FROM dual UNION ALL
8 SELECT TO_DATE('01/12/2008','dd.mm.yyyy') AS dt, 6 FROM dual)
9 -- END OF TEST DATA
10 SELECT EXTRACT(year FROM md.md) as year, EXTRACT(month FROM md.md) as month, count(t.dt) as cnt
11 FROM (select add_months(min_date,rownum-1) as md
12 from (select min(trunc(dt,'MM')) as min_date, max(trunc(dt,'MM')) as max_date from t)
13 connect by rownum <= months_between(max_date,min_date)+1) md
14 LEFT OUTER JOIN t ON (trunc(t.dt) = md.md)
15 GROUP BY EXTRACT(year FROM md.md), EXTRACT(month FROM md.md)
16 ORDER BY 1,2
17
SQL> /
YEAR MONTH CNT
2007 3 1
2007 4 0
2007 5 1
2007 6 0
2007 7 0
2007 8 0
2007 9 0
2007 10 0
2007 11 0
2007 12 0
2008 1 2
2008 2 2
2008 3 0
2008 4 0
2008 5 0
2008 6 1
2008 7 0
2008 8 0
2008 9 0
2008 10 0
2008 11 0
2008 12 1
22 rows selected.
SQL> -
How to derive date from given month, year and day?
Hi all,
I have a doubt in date function. I need to create a date from the given month, year and day. How can i do it?consider this example
REPORT zconvertdate001 .
TYPES : BEGIN OF tt_date_in,
day(2),
sep1,
month(3),
sep2,
year(4),
END OF tt_date_in.
DATA : wa_date_in TYPE tt_date_in VALUE '07-Jul-2006'.
TYPES : BEGIN OF tt_date_out,
day(2),
month(2),
year(4),
END OF tt_date_out.
DATA : wa_date_out TYPE tt_date_out.
TRANSLATE wa_date_in-month TO UPPER CASE.
SELECT SINGLE mnr
INTO wa_date_out-month
FROM t247
WHERE spras EQ sy-langu
AND ktx EQ wa_date_in-month.
CONCATENATE wa_date_in-year wa_date_out-month wa_date_in-day
INTO wa_date_out.
WRITE : / ' Date in:', wa_date_in,
/ 'Date out:', wa_date_out. -
How to compare table's date field with dropdown year field
Hi All,
I have one requirement to display the selected rows from a database table based on the selection of drop down.
Here, I have one dropdown of year(like 2009,2010,....) and I have one database table which contains one field with "DATE".
Now, I want to compare table's DATE field with my dropdown field.
Problem is that table's DATE field is of type "DATS" and dropdown is of type INTEGER(or) STRING ...
How to compare this fields?
Can any one please give me solution for this...!
Thanks in Advance!Hi sreelakshmi.B,
try the following:
DATA lt_dats TYPE TABLE OF dats.
DATA l_dat_i TYPE i.
DATA l_dat_c_4(4) TYPE c.
DATA l_dat_c_12(12) TYPE c.
DATA l_dats_from TYPE dats.
DATA l_dats_to TYPE dats.
*Move Date from Integer to Char
l_dat_c_4 = l_dat_i = 2005.
*Create Date From use in WHERE-Clause
CONCATENATE '01.01.' l_dat_c_4 INTO l_dat_c_12.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = l_dat_c_12
IMPORTING
date_internal = l_dats_from
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*Create Date To use in WHERE-Clause
CONCATENATE '31.12.' l_dat_c_4 INTO l_dat_c_12.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = l_dat_c_12
IMPORTING
date_internal = l_dats_to
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
* Select records in range
SELECT *
FROM [DBTAB]
INTO TABLE [ITAB]
WHERE [DATE] BETWEEN l_dats_from
AND l_dats_to.
Regards
REA -
Strange behaviour of data field in Monthly Invoice.
Dear all,
I need to create new layout for monthly invoice using Print Layout Designer. I need to add the closing date procedure code, so I create new data field refering to the Closing Date Procedure file. This first data field shows many files. But when I want to add another new data field, this second data field only shows the Administration and Closing Date Procedure file. I need to add field from other file, but it does not appear.
If I delete the second data field, I can find the file I need in the first data field (the one supposed to be fill with closing date procedure code).
Is there any idea how to get other files in the second data field ?
By the way, I am using SBO version 2004.2b for Japanese user, and monthly invoice is an important function in Japan.
Thank you very much,
EmilianaThank you, Adele.
Do you also know how to display list of the variables used in the monthly invoice layout ?
Thanks again.
Emiliana -
Querying a date field with different masks in form and database
Dear friends,
I have a field with date format mask dd/mm/yyyy hh24:mi:ss, but the same field has date format dd/mm/yyyy inside the form which queries it.
If I run this form, obviously I will query this date in dd/mm/yyyy format mask, but this date is not being found because it doesn't include hh24:mi:ss (hour) from the database field.
How can I solve this problem? I tried to change my form, putting a format mask with hours, but it requires me to query this date with time, and obviously no one needs to know the exact moment (with seconds!) when the date was recorded in the database.
Thanks, and best regards,
FranklinFranklin,
You could instruct your users to use the '%' when they enter a date search criteria. Another alternative would be to programatically add the '%' to the date. Also, if your Block based on a view you could alter the vuew to use TRUNC() on the date field to drop the time.
Another option would be to use the Pre-Query trigger to modify the Block WHERE clause to: TRUNC(date_field) = :block.date_field.
Hope this helps.
Craig...
-- If my response or the response of another is helpful or answers your question, please mark the response accordingly. Thanks! -
Convert date format from MONTH-YEAR to dd/mm/yyyy
Dear All
i want to get parameter in form of MONTH-YEAR AND WANT TO CONVERT DATE INTO 'THIS FORMAT dd/mm/yyyy' IT GIVES ME ERROR PLEASE GUIDE.
SELECT
TO_CHAR (PTP.END_DATE,'MONTH-YY') ,
to_date ( TO_CHAR (PTP.END_DATE ,'DD-MONTH-YYYY') ,'dd/mm/yyyy'),
--- i want to gent parameter in from of MONTH-YEAR AND WANT TO CONVERT DATE INTO 'THIS FORMAT dd/mm/yyyy' IT GIVES ME ERROR PLEASE GUIDE
to_date ( TO_CHAR (PTP.END_DATE ,'MONTH-YYYY') ,'dd/mm/yyyy'),
ADD_MONTHS((to_date ( TO_CHAR (PTP.END_DATE ,'MONTH-YYYY') ,'dd/mm/yyyy'),-1)
--- i want to gent parameter in from of MONTH-YEAR AND WANT TO CONVERT DATE INTO 'THIS FORMAT dd/mm/yyyy' IT GIVES ME ERROR PLEASE GUIDE
ptp.END_DATE PERRIODS_NAME
from per_time_periods ptp
Regards
Edited by: user10941925 on Nov 28, 2011 12:23 AMHello just check
SQL> select hiredate from emp;
HIREDATE
17-DEC-80
20-FEB-81
22-FEB-81
02-APR-81
28-SEP-81
01-MAY-81
09-JUN-81
09-DEC-82
17-NOV-81
08-SEP-81
12-JAN-83
03-DEC-81
03-DEC-81
23-JAN-82
14 rows selected.
SQL> select to_char(hiredate,'month-year') from emp;
TO_CHAR(HIREDATE,'MONTH-YEAR')
december -nineteen eighty
february -nineteen eighty-one
february -nineteen eighty-one
april -nineteen eighty-one
september-nineteen eighty-one
may -nineteen eighty-one
june -nineteen eighty-one
december -nineteen eighty-two
november -nineteen eighty-one
september-nineteen eighty-one
january -nineteen eighty-three
december -nineteen eighty-one
december -nineteen eighty-one
january -nineteen eighty-two
14 rows selected.
SQL> select to_char(hiredate,'dd/mm/yyyy') from emp;
TO_CHAR(HI
17/12/1980
20/02/1981
22/02/1981
02/04/1981
28/09/1981
01/05/1981
09/06/1981
09/12/1982
17/11/1981
08/09/1981
12/01/1983
03/12/1981
03/12/1981
23/01/1982
14 rows selected.
SQL> -
Query the date field for specific time
I need to be able to run a query on a date field that retrieves specified times.
Any ideas???You could do something like
SELECT *
FROM someTable
WHERE to_char(date_column, 'HH24:MI:SS') = '17:01:04';Justin -
Spread Data Over Multiple Months & Years with Data from Multiple Years
Hello Everyone,
I have a complex calculation for spreading values over several months spanning mulitle years. Because we have a 36 month rolling Forecast, a more sophisticated calc is required as opposed to hard coding months or years.
Heres the description:
Users enter the following data,
FY11 BegBalance Number of BOD Members 10
BOD Options Vesting Months 20
BOD Options Accounting Value 10
BOD Options- Number of Shares 100
BOD Grant Month Aug
FY12 BegBalance Number of BOD Members 5
BOD Options Vesting Months 10
BOD Options Accounting Value 5
BOD Options- Number of Shares 200
BOD Grant Month Oct
FY13 BegBalance Number of BOD Members 20
BOD Options Vesting Months 8
BOD Options Accounting Value 20
BOD Options- Number of Shares 100
BOD Grant Month Feb
Based on the above;
"BOD Stock" is calculated as following/month=Number of BOD Members*BOD Options Accounting Value*BOD Options- Number of Shares/ BOD Options Vesting Months
Start month for the above is based on "BOD Grant Month". So, for instance considering data for FY11:
The total "BOD Stock" value is $10000 (originating from FY11) with start month of AUG in FY11 and the number of months to spread over is 20 months. So, essentially the "BOD Stock" per month (originating from FY11) is $500 starting from AUG FY11 to Mar FY13.
Similarly, the total "BOD Stock" value is $5000 (originating from FY12) with start month of OCT in FY12 and the number of months to spread over is 10 months. So, essentially the "BOD Stock" per month (originating from FY12) is $500 starting from OCT FY12 to JUL FY13.
The challange I am facing is because of the number of months to spread. Because I have data to spread from multiple years and each year's data spills into the following years, each year should accumulate data from prior years. For instance;
FY11 should include only FY11
FY12 should include FY11 and FY12
FY13 should include FY11, FY12 and FY13.
Could anyone suggest a smarter way to do this without writting code for each year, maybe using @MDALLOCATE function? The following shows how data should be spread and accumulated.
BegBalance Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Period
FY11 Number of BOD Members 10 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options Vesting Months 20 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options Accounting Value 10 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options- Number of Shares 100 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Grant Month Aug #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Stock 10000 #mi #mi #mi #mi #mi #mi #mi 500 500 500 500 500 #mi
FY12 Number of BOD Members 5 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options Vesting Months 10 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options Accounting Value 5 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options- Number of Shares 200 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Grant Month Oct #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Stock 5000 500 500 500 500 500 500 500 500 500 1000 1000 1000 #mi
FY13 Number of BOD Members 20 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options Vesting Months 8 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options Accounting Value 20 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Options- Number of Shares 100 #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Grant Month Feb #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi #mi
BOD Stock 40000 1000 6000 6000 5500 5500 5500 5500 5000 5000 #mi #mi #mi #mi
Appreciate your inputs!
Edited by: user10678366 on Oct 12, 2010 3:21 PMWhy not use substitution variables for Years? you could have something like &Year1, &Year2, &Year3
Cheers -
SAPbouiCOM.DBDataSource.Query and Date fields
When I try to add a Condition that uses an Alias for a database field of type datetime, the Query method crashes.
Is there a specific Date format that I am supposed to use?
I am currently using the SAP date format and I also tried the database date format. Both crashed the Query method.My customer's date format is mm/dd/yy and that is the format I was using. Here is what my code looks like for debugging this problem which is still crashing on the Query method:
conditions = new SAPbouiCOM.Conditions();
condition = conditions.Add();
condition.Alias = "U_PLS_PkgD";
condition.Operation = SAPbouiCOM.BoConditionOperation.co_GRATER_EQUAL;
condition.CondVal = "03/11/2004";
dbDataSource.Query(conditions);
I have also tried the following date formats:
condition.CondVal = "11/03/2004";
condition.CondVal = "03-11-2004";
condition.CondVal = "2004-11-01";
"U_PLS_PkgD" is a field in my user table that is of type datetime in the database. I can Query with varchar and int database fields. Just not datetime fields.
Please advise. Thank-you.
Maybe you are looking for
-
Sync'ing contacts with Outlook no longer works
Ipod Nano 4gb with latest iTunes 7.02.16. Problem was also present on previous version of iTunes. At one time, for a while after I bought my iPod nano, I could sync my Outlook contacts. It used to popup a message in Outlook asking for permission and
-
/CAB* function modules in ECC 6.0 DIMP
Hi all, The /CAB 4.6 objects are does not exist in ECC 6.0. I am working on upgradation project. There are many /CAB function modules used in 4.6 version. How can i get the compatable function modules in ecc 6.0. Is there anyway to find the co
-
MM- Subcontract PO - Movement 543 before 101
We would like to de-link the GR and GI in a subcontract PO. We would like to post movement 543 (GI from subcontractor) first and then independently post GR for the subcontract PO. Any thoughts on how this can be accomplished?
-
Silent install for Captivate 4
Hello, I have tried to use the KB 325175 and apply the same command line used in Captivate 3 to the new Captivate 4: setup.exe /s /v"/qn SERIALNUMBER=\"xxxxxxxxxxxxxxxxxxxxxxxx\" ALLUSERS=1 REBOOT=ReallySuppress" However, I got full user interface an
-
BAPI to change customer contact detials
Hi All I am trying to change the value of field ADR2-R3_user with a custom FM , this field is the mobile flag and updated internallly when there telphone number is mobile on the screen tcode VAP2. FM should be able to change the flag . Thanks in adv