Extraing Month part from date value in varchar column
Guys,
I have varchar2 column contains date value in the format '2013/10/03' and i want extract month part of it.
Iam doing like this TO_CHAR(TO_DATE(L_BATCH_DATE,'MM'))='10'
and it says 'not a valid month'.any ideas? and how to get that value?
Cheers
Hi,
Is this are you trying.
to_date --> we will use this function to inform oracle the date is in character mode with this format
to_date('2013/10/03','yyyy/dd/mm')
select to_char(to_date('2013/10/03','yyyy/dd/mm'),'mm') from dual;
Similar Messages
-
hi,
I have a query in Informix which get the month part of a date. Please help me in converting the same to oracle.
Informix query
select month(col1 - today) from tab1;
col1 is a date field, today will yield the current date and month function will get the month of the date.
In oracle, when we subtract two dates we will get a number value, how to convert that back to date and extract the month part.
Help me?????
Regards,
GopuIf your looking for the number of months between two dates:
SQL> select months_between(sysdate, trunc(sysdate,'yyyy')) from dual ;
MONTHS_BETWEEN(SYSDATE,TRUNC(SYSDATE,'YYYY'))
6.06223081
Just replace my usage of sysdate (etc) with the dates your using...
Hope that helped,
Stan -
Extract Month & Year From Date
Hi All,
I have a key figure quantity and i want the data on date,for the month and for the year.
i create the variables for the date,for the month(ie from date to date) and for the year(ie, from date to date) seperatly that means i have three input variables which may sometimes create confusion.
My problem is that I want to enter only date and the variable itself calculate the month and year from the date so that it returns the data as desired above.
for eg. : Now i to enter date : 3/14/2009
enter MTD (FROM/TO) : 3/01/2009 - 3/14/2009
enter YTD (FROM/TO) : 4/01/2008 - 3/14/2009
I want to enter only date : 3/14/2009
and the variable itself extract the month and year till date.
and also the same variable calculates number of days so that need not to take the formula variable of date difference to calculate the average qty.
Neha..Hi,
1. Create User Entry Variable on 0CALDAY : Name = ZCDAY.
2. Craete a Customer Exit Variable on 0CALDAY: Name = ZMTD.
3. Craete a Customer Exit Variable on 0CALDAY: Name = YMTD.
Properties of Customer Exit Variables.
Variable reporesents = Single
Variable Entry = Mandatory
Processing By = Customer Exit.
Character = Calender Day
Here I'm thinking that ZKF is your key figure.
In columns you create two selections one is for MTD and other is for YTD.
In MTD selection, drag and drop ZKF and Drag and Drop 0CALDAY and then Right Clcik and Restrict-->
Selection = Value Range. (In Between) and restrict with the follwoing Variables
[]ZMTD; ZCDAY.
In YTD selection, drag and drop ZKF and Drag and Drop 0CALDAY and then Right Clcik and Restrict-->
Selection = Value Range. (In Between) and restrict with the follwoing Variables
[]YTD; ZCDAY.
Then write the following code in I_STEP = 2.
DATA: ZT_DT1 TYPE SY-DATUM,
ZT_DT2 TYPE SY-DATUM,
ZT_SDT TYPE SY-DATUM,
ZT_YR(4) TYPE N,
ZT_DY(2) TYPE N,
ZT_MT(2) TYPE N,
ZE_TT(2) TYPE N,
ZPOPER TYPE POPER,
ZRELJR TYPE RELJR.
WHEN 'ZMTD_A'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCDAY'.
IF sy-subrc = 0.
CLEAR: l_s_range.
ZT_DY = '01'.
ZT_SDT = loc_var_range-low.
ZT_MT = ZT_SDT+4(2).
ZT_YR = ZT_SDT+0(4).
CONCATENATE ZT_YR ZT_MT ZT_DY INTO ZT_DT1.
l_s_range-low = ZT_DT1.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDLOOP.
WHEN 'ZYTD'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCDAY'.
IF sy-subrc = 0.
CLEAR: l_s_range.
ZT_DY = '01'.
ZT_SDT = loc_var_range-low.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = ZT_SDT
* I_MONMIT = 00
I_PERIV = 'V3'
IMPORTING
E_BUPER = zbuper
E_GJAHR = zbdatj
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
EXPORTING
I_GJAHR = zbdatj
I_PERIV = 'V3'
IMPORTING
E_FIRST_DAY = ZT_DT2
* E_LAST_DAY =
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
l_s_range-low = ZT_DT2.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDLOOP.
Thanks
Reddy -
How to derive month/year from date in SAP BW 3.5 data flow
Hi
How we can derive cal year/month and fiscal month/year from date in SAP BW 3.5 data flow (we're using transfer and update rule)..
Thanks,
PKHi,
if you have any date filed in source side you can just map to any time char system will automatically convert to target objects.
please look at the screen shot for understanding. (not 3.x it is 7.x)
Thanks,
Phani. -
How to get a time part from Date datatype
Hi,
I would like to know how to extract the timestamp alone from DATE datatype? If my input is '27-SEP-2011 23:59:00' I need the output as 23:59:00. I am surprised to see that there are no in-built functions for this or may be I am wrong. Basically I need to remove the date part from DATE data type and get the time.Please assist.
-Thanks
Edited by: user9546145 on Sep 27, 2011 2:24 PM
Edited by: user9546145 on Sep 27, 2011 2:25 PMHi,
user9546145 wrote:
Hi,
I would like to know how to extract the timestamp alone from DATE datatype? Be careful! In Oracle, TIMESTAMP means a datatype, similar to but distinct from DATE. You'll avoid confusion if you don't use the word "timestamp" to mean anything else.
There is a built-in function, TO_CHAR:
TO_CHAR (dt_col, 'HH24:MI:SS')Depending on how you plan to use the time, TRUNC is another handy built-in function:
dt_col - TRUNC (dt_col)is a NUMBER (not less than 0, but less than 1) which is suitable for many tasks, such as finding the average time.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using. -
FM for getting MONTH name from DATE.
Hi all ,
We have a requirement to get Month name from the DATE,e.g IF date is 01/01/2008 we need a FM which can generate month name as 'JANUARY'.
\[removed by moderator\]
Thanks and Regards
Kiran
Edited by: Jan Stallkamp on Jul 30, 2008 4:26 PMHi,
Here is the code u required...
REPORT ZASHU_MONTH_NAMES_GET.
data:r_code type sy-subrc.
data:mnames type standard table of T247 with header line.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE = r_code
TABLES
month_names = mnames.
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write:/ mnames.
Thanks & Regards
Ashu Singh -
Week and month calculation from date column
I have 3 column data like
with tab as
select 'Topshop' brand, '10-JUL-11' deliverydate, '100' qty from dual union all
select 'Topshop' brand, '10-JUL-11' deliverydate, '400' qty from dual union all
select 'NewSita' brand, '11-JUL-11' deliverydate, '200' qty from dual union all
select 'LaGress' brand, '12-JUL-11' deliverydate, '300' qty from dual union all
select 'LaGress' brand, '10-AUG-11' deliverydate, '100' qty from dual union all
select 'LaGress' brand, '11-AUG-11' deliverydate, '200' qty from dual union all
select 'Topshop' brand, '12-AUG-11' deliverydate, '300' qty from dual union all
select 'NewSita' brand, '10-SEP-11' deliverydate, '100' qty from dual union all
select 'Topshop' brand, '11-SEP-11' deliverydate, '200' qty from dual union all
select 'NewSita' brand, '12-SEP-11' deliverydate, '300' qty from dual
) select * from tabI need to convert it into 4 columns
Brand | Month | Week(start date) | Qty (sum)
Please let me know what are the options that i have, especially the date-time calculation functions available to solve such problems.
Thanks
w\with tab as
select 'Topshop' brand, to_date('10-JUL-11', 'dd-mon-yy') deliverydate, '100' qty from dual union all
select 'Topshop' brand, to_date('10-JUL-11', 'dd-mon-yy') deliverydate, '400' qty from dual union all
select 'NewSita' brand, to_date('11-JUL-11', 'dd-mon-yy') deliverydate, '200' qty from dual union all
select 'LaGress' brand, to_date('12-JUL-11', 'dd-mon-yy') deliverydate, '300' qty from dual union all
select 'LaGress' brand, to_date('10-AUG-11', 'dd-mon-yy') deliverydate, '100' qty from dual union all
select 'LaGress' brand, to_date('11-AUG-11', 'dd-mon-yy') deliverydate, '200' qty from dual union all
select 'Topshop' brand, to_date('12-AUG-11', 'dd-mon-yy') deliverydate, '300' qty from dual union all
select 'NewSita' brand, to_date('10-SEP-11', 'dd-mon-yy') deliverydate, '100' qty from dual union all
select 'Topshop' brand, to_date('11-SEP-11', 'dd-mon-yy') deliverydate, '200' qty from dual union all
select 'NewSita' brand, to_date('12-SEP-11', 'dd-mon-yy') deliverydate, '300' qty from dual
), week_data as (
select brand
, to_char(deliverydate, 'Month', 'nls_date_language=american') MON
, trunc(deliverydate, 'day') WEEK_START
, sum(TO_NUMBER(qty)) SUM_QTY
from tab
group by brand
, to_char(deliverydate, 'Month', 'nls_date_language=american')
, trunc(deliverydate, 'day')
), weeks as (
select
w.week_min + (level - 1) * 7 week_start
from (
select min(week_start) week_min, max(week_start) week_max
from week_data
) w, dual
connect by level <= 1 + (w.week_max - w.week_min) / 7
select
week_data.brand,
weeks.week_start,
nvl(week_data.sum_qty,0) sum_qty
from week_data
partition by (brand)
right outer join weeks
on (weeks.week_start = week_data.week_start)
order by
weeks.week_start,
week_data.brand;You construct a set of records of all "week_start" dates from your minimum to your maximum (classic connect by level trick.)
You use a partitioned outer join to fill in the gaps in your sparse data (see doc example [url http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_10002.htm#i2177515]here.
Hope that helps you :-)
(PS. I dislike implicit conversions - that is the only reason I have added a TO_NUMBER to your code within the sum() ;-) )
(PPS. Actually you probably should have asked this in a new question - I believe it is not really good forum etiquette to continue in a thread that has already been answered...) -
Parsing VARCHAR to DATE where the VARCHAR column has multiple format
Hello,
I'm a little stumped here so I figured I'd try posting here.
I have an application where I can not alter the code. This application has a form with a calender conrol on it that allows the user to select a date. This form is internationalized so date formats vary based on the country the user is coming form (mm/dd/yyyy, dd-Mon-yyyy, dd.mm.yyyy, etc). The application saved the string of the date as the calender control returns to the form, it does not save the value as a date value.
I need to preform a query that can do some cacluations off of this date. When there is only one date format returned in the query, there is no problem
CASE WHEN TO_DATE(d3.data,'Mon/dd/yyyy')-NVL(trunc(i3.end_date),trunc(SYSDATE)) < 0 THEN calc_business_days(TO_DATE(d3.data,'Mon/dd/yyyy'),NVL(trunc(i3.end_date),trunc(SYSDATE)))
WHEN TO_DATE(d3.data,'Mon/dd/yyyy')-NVL(trunc(i3.end_date),trunc(SYSDATE)) > 0 THEN 0-(calc_business_days( NVL(trunc(i3.end_date),trunc(SYSDATE)) ,TO_DATE(d3.data,'Mon/dd/yyyy')))
ELSE 0 END
However, this errors when there are multiple formats in the varchar column for the same query. Can anyone provide any guidance on how to handle this? I am using Oracle 10g.
ThanksThe simplest option is generally to create a new function that does the conversion and sets up a hierarchy of date formats. Obviously, there may be some data loss here-- '01/02/03' is a valid string in the format mm/dd/yy, dd/mm/yy, and yy/mm/dd but it means different things in each.
Something like
CREATE OR REPLACE FUNCTION my_to_date( p_in_string VARCHAR2 )
RETURN date
IS
BEGIN
RETURN to_date( p_in_string, 'MM/DD/YYYY' );
EXCEPTION
WHEN others THEN
BEGIN
RETURN to_date( p_in_string, 'DD-MON-YYYY' );
EXCEPTION
WHEN others THEN
BEGIN
RETURN to_date( p_in_string, 'DD.MM.YYYY' );
EXCEPTION
WHEN others THEN
RETURN NULL;
END;
END;
END;
/Justin -
How to validate Date value in Text Column
Hi All,
I have entered DATE value in text item field(Char Data Type), Now how can i validate, the entered date is valid or not.
Thanks in advance.Well, the easiest way would be to make the item of datatype DATE.
Another possibility is to try to convert the given value to a date in the WHEN-VALIDATE-ITEM-trigger, like
DECLARE
dt DATE;
BEGIN
dt:=TO_DATE(:BLOCK.ITEM);
-- if code comes here, the date is valid
EXCEPTION
WHEN OTHERS THEN
-- seems to be no valid date
MESSAGE('Error');
RAISE FORM_TRIGGER_FAILURE;
END;Edited by: Andreas Weiden on 19.12.2010 12:23 -
Year , Month & Day from Date.
Hi HANA experts,
Do help me to resolve this issue
How can we extract or fetch year from the date.i went through some of the SCN blogs.where they create calculation views...but the steps are not that clear to me.
can anyone please explain??
My scenario is :
I have date field in ANALYTIC VIEW which i have fetched from ECC tables.
now i need to get the year wise month wise and day wise reports. so what steps i should do in calculation view to get that??
thanks
Neerajathere is no ECC under SAP...as we are using suite on HANA fro AWS.and there is no restriction done by the basis till now...
as we are new to these unable to trouble shoot things easily.
thanks for your reply.. -
How to Calculate column (Month, Year) from date or timestamp
Hi,
Name
SQL Data Type
Dimension
Column Store Data Type
Key
Not Null
Default
Comment
T_STAMP
TIMESTAMP
LONGDATE
How to generate Month and Year from timestamp field in Analytic View.
Please provide me some valuable input. I have searched SCN before posting this discussion.Hi KD,
You can apply the following formulas in the expression:
For Year :
leftstr(string("Timestamp"),4)
For Month:
midstr(string("Timestamp"),6,2)
Regards,
Krishna Tangudu -
Group by month/year from DATE FORMAT column
Hi Chaps,
I have a recordset that pulls data from a database, then presents the data in a table. The data is grouped by 'projid', repeated for every 'projid', with a show/hide control, to show all the 'jobid's' relating to that particular 'projid'
This is what I have so far:
Code:
SELECT
tbl_projects.projid,
tbl_projects.projtitle,
tbl_projects.projdue, DATE_FORMAT(tbl_projects.projdue, '%%d/%%m/%%Y') as projdue_format,
tbl_projects.projtype,
tbl_projects.projinvtype,
tbl_projects.FK_custid,
tbl_projects.projcompletedate
tbl_languaget.langtname,
tbl_doctype.doctypename,
tbl_jobs.jobid,
tbl_jobs.FK_projid,
tbl_jobs.jobname,
tbl_jobs.FK_langid,
tbl_jobs.jobpages,
tbl_jobs.jobshipped,
tbl_jobs.jobinvsent,
tbl_jobs.jobtranslatorcharge,
'tbl_jobs' as fromtable,
tbl_customers.custid,
FROM tbl_projects
INNER JOIN tbl_jobs
ON tbl_projects.projid=tbl_jobs.FK_projid
INNER JOIN tbl_languaget
ON tbl_languaget.langtid=tbl_jobs.FK_langid
INNER JOIN tbl_customers
ON tbl_customers.custid=tbl_projects.FK_custid
INNER JOIN tbl_costs
ON tbl_costs.FK_custid=tbl_customers.custid
INNER JOIN tbl_doctype
ON tbl_doctype.doctypeid=tbl_jobs.FK_doctypeid
WHERE tbl_projects.projstatus='Complete'
AND tbl_projects.projinvtype='Costing Sheet'
AND langtname!='TH'
AND langtname!='ID'
AND langtname!='KO'
AND langtname!='JP'
AND jobinvsent='y'
AND FK_custid = %s
ORDER BY projid ASC", GetSQLValueString($colname_rsInvPending, "int");
$rsInvPending = mysql_query($query_rsInvPending, $conndb2) or die(mysql_error());
//$row_rsInvPending = mysql_fetch_assoc($rsInvPending);
$totalRows_rsInvPending = mysql_num_rows($rsInvPending);
Code:
// REPEAT - FOR EVERY PROJECT
<?php
$previousProject = '';
if ($totalRows_rsInvPending > 0) {
// Show if recordset not empty
while ($row_rsInvPending = mysql_fetch_assoc($rsInvPending)) {
if ($previousProject != $row_rsInvPending['projid']) {
// for every Project, show the Project ID
?>
Code:
// SHOW/HIDE CONTROL
<tr>
<td colspan="9" class="highlight"><span class="blueBold"><a href="#" onclick="toggle2('proj1<?php echo $row_rsInvPending['projid'] ?>', this)"><img src="../../Images/plus.gif" border="0" /></a> <?php echo $row_rsInvPending['projid'] ?> - </a></span><span class="blueNOTBold"><em><?php echo $row_rsInvPending['projtitle'] ?></em></span></td>
</tr>
Code:
// SHOW/HIDE
<?php $previousProject = $row_rsInvPending['projid']; } ?>
<tr class="proj1<?php echo $row_rsInvPending['projid'] ?>" style="display:none">
<td>column 1</td>
<td>column 2</td>
What I want, is to put in another grouped by stage, where the 'projid's' themselves are in a show/hide region, grouped by 'projcompletedate' (year/month). 'projcompletedate' is in DATE format, but how to I get PHP/SQL to take the month and year and then group them correctly?Hi David, I'm not sure if I've got this right, would you mind looking at my latest code?:
<table border="0" cellpadding="0" cellspacing="0" id="tblinvoice">
<tr>
<th>Job Title</th>
<th>Type</th>
<th>Language</th>
<th>Translator</th>
<th>Total</th>
<th>Full</th>
<th>Fuzzy</th>
<th>Proof</th>
<th>Full Price</th>
<th>Discount Price</th>
<th>Document Format</th>
<th>Pages</th>
<th>Typesetting Cost</th>
<th>EN Proofreading Cost</th>
<th>Total</th>
<th>Translator Charge</th>
<th>Profit</th>
<th>Profit Percentage</th>
</tr>
<?php
$previousMonth = '';
if ($totalRows_rsInvPending > 0) {
// Show if recordset not empty
do ($row_rsInvPending = mysql_fetch_assoc($rsInvPending)) {
if ($previousMonth != $row_rsInvPending['themonth']) {
// for every Month, show the Month Name
?>
<tr>
<td colspan="18" class="highlight"><?php echo $row_rsInvPending['theyear'] ?> - <?php echo $row_rsInvPending['themonth'] ?></td>
</tr>
<?php $previousMonth = $row_rsInvPending['themonth']; } ?>
<?php
$previousProject = '';
if ($totalRows_rsInvPending > 0) {
// Show if recordset not empty
while ($row_rsInvPending = mysql_fetch_assoc($rsInvPending)) {
if ($previousProject != $row_rsInvPending['projid']) {
// for every Project, show the Project ID
?>
<tr>
<td colspan="18" class="highlight"><span class="blueBold"><a href="#" onclick="toggle2('proj1<?php echo $row_rsInvPending['projid'] ?>', this)"><img src="../../Images/plus.gif" border="0" /></a> <?php echo $row_rsInvPending['projid'] ?> - </a></span><span class="blueNOTBold"><em><?php echo $row_rsInvPending['projtitle'] ?></em></span></td>
</tr>
<?php $previousProject = $row_rsInvPending['projid']; } ?>
<tr class="proj1<?php echo $row_rsInvPending['projid'] ?>" style="display:none">
<td><?php echo $row_rsInvPending['jobname']; ?></td>
<td><?php echo $row_rsInvPending['projtype']; ?></td>
<td><?php echo $row_rsInvPending['langtname']; ?></td>
<td><?php echo $row_rsInvPending['translator']; ?></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php } while ($row_rsInvPending = mysql_fetch_assoc($rsInvPending)); ?>
<?php } // Show if recordset not empty ?> -
Extract Year/Month/ Week From Date
BW Experts,
I have a Time Char in a New OSD i am developing. Say the Time char is 0Req_date. This 0req_date is updated using some calculation in my update rules (Say 0Req_Date = Act_dl_dt - Conf_date). Now I have to extract month/ year/ week and populate Time Chars 0REQ_MONTH, 0REQ_YEAR and 0REQ_WEEK respectively from 0REQ_DATE. Can I do this via respective rules to 0REQ_MONTH, 0REQ_YEAR and 0REQ_WEEK in the update rules. My concern is as OREQ_DATE itself is a calculated field, can month/year/week be extracted correctly? Hope I have put the question across understandably. Help is appreciated.
Thanks
AshwinHi Ashwin,
It can be done...you can either put the code for all these derivations in the Start Routine of the update rule, making sure that the 0REQ_Date is calculated before the others. Or you can also calculate just the 0REQ_DATE in the start routine and use the individual update routines to populate the other time chars.
Processing using the Start Routine is recommended for efficiency and better performance.
Hope this helps... -
Convert date value in 1 column help
Am on 10g.
I have a column: STAMP_DATE with these values:
I need to leave LEGACY as it is, but everything else, I need to convert it to: MMYYYY as in: 092010 for example.
So 9-Sep stands for Sep-2009. The digit is the year, I am trying to fix this.
Any SQL help would be appreciated, thank you!
STAMP_DATE
"LEGACY"
"9-Sep"
"9-Oct"
"9-Nov"
"9-May"
"9-Mar"
"9-Jun"
"9-Jul"
"9-Dec"
"9-Aug"
"9-Apr"
"10-May"
"10-Mar"
"10-Jan"
"10-Feb"
"10-Apr"
These values were imported from Excel using SQLLDR, so it kinda made them like that.maybe this might help.
SQL> select to_char(to_date(lg.stamp_date||'-'||to_char(sysdate,'yyyy'),'dd-mon-yyyy'),'mmyyyy') STAMP_DATE
2 from (select 'LEGACY' STAMP_DATE from dual union all
3 select '9-Sep' STAMP_DATE from dual union all
4 select '9-Oct' STAMP_DATE from dual union all
5 select '9-Nov' STAMP_DATE from dual union all
6 select '9-May' STAMP_DATE from dual union all
7 select '9-Mar' STAMP_DATE from dual union all
8 select '9-Jun' STAMP_DATE from dual union all
9 select '9-Jul' STAMP_DATE from dual union all
10 select '9-Dec' STAMP_DATE from dual union all
11 select '9-Aug' STAMP_DATE from dual union all
12 select '9-Apr' STAMP_DATE from dual union all
13 select '10-May' STAMP_DATE from dual union all
14 select '10-Mar' STAMP_DATE from dual union all
15 select '10-Jan' STAMP_DATE from dual union all
16 select '10-Feb' STAMP_DATE from dual union all
17 select '10-Apr' STAMP_DATE from dual) lg
18 where lg.stamp_date != 'LEGACY'
19 union all
20 select lg.stamp_date STAMP_DATE
21 from (select 'LEGACY' STAMP_DATE from dual union all
22 select '9-Sep' STAMP_DATE from dual union all
23 select '9-Oct' STAMP_DATE from dual union all
24 select '9-Nov' STAMP_DATE from dual union all
25 select '9-May' STAMP_DATE from dual union all
26 select '9-Mar' STAMP_DATE from dual union all
27 select '9-Jun' STAMP_DATE from dual union all
28 select '9-Jul' STAMP_DATE from dual union all
29 select '9-Dec' STAMP_DATE from dual union all
30 select '9-Aug' STAMP_DATE from dual union all
31 select '9-Apr' STAMP_DATE from dual union all
32 select '10-May' STAMP_DATE from dual union all
33 select '10-Mar' STAMP_DATE from dual union all
34 select '10-Jan' STAMP_DATE from dual union all
35 select '10-Feb' STAMP_DATE from dual union all
36 select '10-Apr' STAMP_DATE from dual) lg
37 where lg.stamp_date = 'LEGACY';
STAMP_DATE
092010
102010
112010
052010
032010
062010
072010
122010
082010
042010
052010
032010
012010
022010
042010
LEGACY
16 rows selected
SQL> -
Using the EXTRACT function to get year and month from date
Hello~
I am trying to extract the month and year using the query below but am getting the error:
Query cannot be parsed within the Builder
select distinct city AS "CITY",count(MOTOR_ASSIST2.CITY) as "COUNT"
from "MOTOR_ASSIST2" "MOTOR_ASSIST2"
where
(:P53_FISCAL_YR IS NULL OR :P53_FISCAL_YR = MOTOR_ASSIST2.FY)
*OR (:P53_MONTH IS NULL OR EXTRACT(MONTH FROM :P53_MONTH) = MOTOR_ASSIST2.DATETIME)
OR (:P53_YEAR IS NULL OR EXTRACT(YEAR FROM :P53_YEAR) = MOTOR_ASSIST2.DATETIME))*
GROUP BY MOTOR_ASSIST2.CITY
ORDER BY CITY
Can anyone help me figure out what im doing wrong?Thanks
Deanna1. Whats the value of year you are passing here ??
2. Whats the value of months you are passing here??
Select City As "CITY", Count(Motor_Assist2.City) As "COUNT"
From "MOTOR_ASSIST2" "MOTOR_ASSIST2"
Where ((:P53_Fiscal_Yr Is Null Or :P53_Fiscal_Yr = Motor_Assist2.Fy) Or
(:P53_Month Is Not Null Or :P53_Month = Motor_Assist2.Month) And
(:P53_Year Is Not Null Or :P53_Year = Motor_Assist2.Year) And
Datetime >= To_Date(:P53_Year||:P53_Month, 'YYYYMON') And
Datetime > Add_Months(To_Date(:P53_Year||:P53_Month, 'YYYYMON'), 1)
Group By Motor_Assist2.City
Order By City
SQL> Select Sysdate From dual Where Sysdate = To_Date('2008'||'SEP', 'YYYYMON');
SYSDATE
Select Sysdate From dual Where Sysdate = To_Date('2008'||'SEP', 'YYYYMON');
SYSDATE
SQL> Select To_Date('2008'||'SEP', 'YYYYMON') From dual;
TO_DATE('2008'||'SEP','YYYYMON
9/1/2008
will give you sept 1st or 1st day of the month,
hows the data in your datetime column or variable ???
SQL> Select Sysdate From dual Where trunc(add_months(last_day(Sysdate),-1) +1) = To_Date('2008'||'SEP', 'YYYYMON');
SYSDATE
9/12/2008 3
SQL>
there both side of '=' yield first day of sept ...
SQL>
Maybe you are looking for
-
Parse xml file with validating againat dtd
i have a xlm file looks like: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE map SYSTEM "map.dtd"> <map width="20" height="15" goal="25" name="eXtreme Labyrinth of Dooom"> <random-item type='lantern' amount='5' /> <random-item type='health' amount=
-
Multiple Browsers not loading some pages
My wife ran into a problem late last night loading her LiveJournal page. Other pages seemed to load, but not that one. At first, we thought it was that site's problem. However, this morning the problem has spread to other sites. YouTube Yahoo and Goo
-
Hi, I am working on ADF popups. I have created a simple popup as shown below: <af:popup id="test" contentDelivery="lazyUncached" > <af:panelWindow modal="true" title="Update Sample Type" closeIconVisible="true"> <af:inputText value="test"/> </af:pane
-
Meaning of "Map To Identifier " while creating an External Content Type
In SharePoint 2010 Desginer, I created an External Content Type that retrieves data from a VIEW in SQL Server. In the wizard, I see "Map To Identifier." What is the purpose of that. I want to understand the meaning of Map To Identifier? Thank you. Ma
-
SURVEY: Blend mode options in Brush tool?
This is a survey question for users of all versions of Fireworks. In Fireworks 8, I've noticed a difference in the Brush tool properties depending on whether the selection is an object or a mask-in particular, the Blend mode options do NOT appear in