Frm-50004: day must be between 1 and last of month.
frm-50004: day must be between 1 and last of month.
hi dear all,
I HAVE A TEXTITEM OF DATATYPE DATE. ITS FORMAT MASK IS 'HH24-MI-SS AM' BUT
WHEN I TRY TO INSERT IT GIVES THE FOLLOWING ERROR:
FRM-50004: Day must be between 1 and last of month.
thanks
Muhammad Nadeem
Mardan (Pakistan)
[email protected]
I don't think you are getting that error message from that date item. Oracle defaults the month to current month, day to 01, and year to current year when they aren't entered in a date.
However, you cannot use 'HH24' with the 'AM' meridian indicator, so that format mask is illegal, and SHOULD generate a different error message.
And last, if you want Forms to carry the time in a date field, you MUST set the datatype to datetime.
Similar Messages
-
Day must be between 1 and last day of month
Hi
I have a master detail form for overtime entries.
Master Block contain emp_no,name,month etc.
Detail block contain a date field ,,from time, to time etc
when i enter the date in detail block it defaults the month from Server date and i am getting the error "Day must be between 1 and last day of ...."
The form is going to reside on server so i cant go for changing system date for that.
THe work around i am trying is i have created a dummy item in detail block for Date(dd) entry and populating my original date field on the basis of it.
so that i can get rid of last day validation of month.The datatype of dummy item is char
my code is
c_day varchar(2);
c_month varchar(2);
c_year varchar(4);
d_date varchar(8);
begin
c_day := :DETAIL.dummy;
c_month := to_char(:MASTER.month, 'mm');
c_year := to_char(:master.month, 'yyyy');
d_date := c_day||c_month||c_year;
:DETAIL.ot_date := to_date(d_date,'ddmmyyyy');
end;
I am using post change trigger on my dummy item but i am getting ORA-01840 for that.I have tried several ways but it is giving different type of date errors for that.
Any help is highly appreciatedDear try this
SELECT RUN_NUM, CV AS MONTH_DATE
FROM
SELECT ROWNUM AS RUN_NUM,TO_DATE('01-' || 'SEP' || '-' || 2007 ,'DD/MM/YYYY')+ (ROWNUM-1) CV
FROM
(SELECT 1 FROM DUAL GROUP BY CUBE (1,1,1,1,1)) A
WHERE TO_CHAR(CV,'MON-YYYY') = 'SEP-2007' -
Need the first day of the year and last day of the year.
hi all,
i need a function module which can get me the first day of current year and last day of the current year??
please help.Similar date questions are being asked ALL THE TIME. Please search.
-
FM for First and Last Day_Current Month
Hello All,
Inorder to update the TVARV table, two new variables were needed which will get the First and Last Day of current month.
One FM i was able to find was BKK_GET_MONTH_LASTDAY which takes the Todays date and outputs the Last date of the month. IS there any FM for FIRSTDAY Current month....
Regs,
-PSKHi Sravan,
Following help may help you.
FM - BUILD_PERIOD_TABLE
code is mentioned below.
data: it_cperiod type table of range_prds with header line,
define one variable as range like -
ranges: r_cperiod for sy-datum,
CALL FUNCTION 'BUILD_PERIOD_TABLE'
EXPORTING
YEAR = <current year>
TABLES
PERIOD_TABLE = it_cperiod.
read table it_cperiod with key per_id = <current month>
refresh r_cperiod.
r_cperiod-sign = 'I'.
r_cperiod-option = 'BT'.
r_cperiod-low = it_cperiod-begda.
r_cperiod-high = it_cperiod-endda.
append r_cperiod.
Now, you can see begin and end of moth in r_cperiod.
Regards,
Parag -
Day must be between 1 and last day of the month
Hi
I have a master detail form .
Master Block contain emp_no,name,month etc.
Detail block contain a date field(format mask 'dd'),a day field(the day on that day)
and working hours detail of each day.
when i enter the date in detail block it defaults the month from system date and i can not enter 31 for the month of march if system date is April.
The form is going to reside on server so i cant go for changing system date for that.What i am looking for is the detail block should get the month from the month field present in master block.For eg if i enter 3 in month field on master block the detail block date field should allow me to enter 1 to 31. if i enter 2 in month field on master block the detail block date field should allow me to enter 1 to 28.and so on. can any body help in this regard.The effective_date only effects the $$ variables such as $$DBDATE$$ but the form uses a different date to complete the partial entry. You can see this if you reset the system time:
ALTER SYSTEM SET fixed_date = '2007-01-01-00:00:00';
and set a date item's initial value to $$DBDATE$$ (and use a full format mask).
With this setting your method still uses the current month.
I don't know what forms uses to populate the date from a partial entry but you could solve your problem by creating a new item for the entry of the day, hide the existing item and populate it in the when-validate trigger of the new item, eg
:block.proper_date_field := to_date(:block.dummy_date_field||:master_block.month||<year>,'DDMMYYYY');
Then you just need to trap the exception if an invalid date is entered.
(and populate the dummy date field in post-query of course).
For forms 10g, and 6i too I think, the post-change trigger is deprecated. Use when-validate-item for this. -
Creation of a Query to show the values for the current month and the last 12 months data.
Dear All,
Good day!
I have to create a Query with the below requirement.
I have to create a Query to show the values for the current month and the last 12 months data.
Can you please guide me how to achieve this ??
thank you,
Regards,
HemaHema
explain the exact problem..? as you mentioned you want to create query to show values for current month and last 12 months.. so I think you want to show values for 12 months from current data.. you can achive this by multiple way..
you can have selection screen and field with date .. and restrict based on system current date and 12 months before or you can handle this at your target.. .. I mean there are multiple ways to restrict data by date range..
for some more hints..
http://www.forumtopics.com/busobj/viewtopic.php?t=34393&sid=7fba465d0463bf7ff5ec46c128754ed6
http://businessintelligence.ittoolbox.com/groups/technical-functional/cognos8-l/how-to-display-last-12-months-in-report-based-on-todays-date-3231850
http://scn.sap.com/thread/3217381
search on SDN you will get many other ways..
Thanks,
Bhupesh -
Month doesn't appear in the axis for last 12 months
Hi !
I have created a graph which gives records for the last twelve months, my formula is:
if {Commande.DATE} >= dateadd('m',-12,currentdate) and {Commande.DATE} <=currentdate then {Commande.DATE}
At this point everything's fine ,
I have to create another formula to have Month name
from today which mean ,the order should be like this on my graph axis, 1st last month is febuary and last 12 months from today is March
March - April - May - June - July - August - September - October - November -December - January Febuary
here is that formula which I have called Month Sort order:
If month({@last12months})=01then
"Janv" else
if month({@last12months})=02 then
"Fév" else
If month({@last12months})=03then
"Mars" else
if month({@last12months})=04 then
"Avril" else
If month({@last12months})=05then
"Mai" else
if month({@last12months})=06 then
"Juin" else
If month({@last12months})=07then
"Juil" else
if month({@last12months})=08 then
"Août" else
If month({@last12months})=09then
"Sept" else
if month({@last12months})=10 then
"Oct" else
If month({@last12months})=11then
"Nov" else
if month({@last12months})=12 then
"Déc" else ""
in the Graph/Chart expert ,in the resulting dialog box I have set the following options:
On Change of: i have set the formula Month Sort order which will bring me the month name and for the order I have set in the Original order .
It works fine I retrieve records for last 12 months but on my axis ,the name for
the last 12 months doesn't appear in this case ( March) it is blank ,I have the records for March but not the month name March in my axis it show april to febuary but not March
Thank you for helping meThank you for your reply , but this doesn't solved my problem ,
I'm using a data from SQL2005 which is a stored procedure ,they have created a datefield named "DATE" and group the data the 1st of each month in this SQL stored procedure ,the only day for each month that I have in this data is the first of each month for each record found ,so I've changed the formula for this, to get records the 1st of each month for the last 12 months :
the new Formula for is:
if >= DateAdd("m",-12,CurrentDate) - day(CurrentDate)+1 and
<=DateAdd("m",-1,CurrentDate) - day(CurrentDate)+1 then
this condition formula bring me _Null datefield_ ,and this is why I see a null label axis at the bottom,do you have an idea how I can eliminate the null datefield , I need to have only the last 12 months data on this graph but I need all data for the past 3 years for 2 other grah on this same report
Thank you very much , -
Hi,
I have created a User Access report for CRM on-premise using SQl query in the following format. One row corresponds to one user in organization. Currently, I am using Microsoft Dynamics CRM Online trial version and have two users in my organization.
I want to the same report for CRM Online environment. Only Fetch-Xml based custom reports are supported by CRM online environment hence this SQL query cannot be used.
I have already written fetch-xml query to retrieve user access records ("audit" entity records) in "last-x-months" (where x = 1,2,3,4,5,6) as below.
I am able to retrieve the records with "last-x-months" condition at a time, for example, the last-2-months in my fetch-xml query only.
For, example, when I retrieve the records in the last-2-months, it also includes the records in the last month. I want to count the records in the 2nd month only that is the difference between these two. The difference will be my 2nd column.
Similarly, I want the other columns.
For the case in the above example, I have created the two separate datasets to get the record-count for the last month and last-2-months. But, I am not able to use the two datasets in the same table in my report and hence not able to calculate the difference.
Is there any way to solve this problem?Hi,
I have modified my Fetch-XML query to retrieve all the required User Access records and removed aggregation and counting and grouping from the query as well. Did grouping and counting in SSRS. Now the report works fine as shown in the above picture. -
Script calc budget whole year from last 6 month figure
HI Expert,
I need to write a script to calculate budget from JAN to DEC base on last six month figure
lets says budget 2010.
to start to calculate 2010.JAN budget..
i need take value from 2009.JUL to 2009.DEC ACTUAL value for calculation..
to calculate 2010.FEB budget..
i need take value from 2009.AUG to 2009.DEC ACTUAL value + 2010.JAN budget value(which is value from above after commit) for calculation...
to calculate 2010.MAR budget..
i need take value from 2009.SEP to 2009.DEC ACTUAL value + 2010.JAN budget + 2010.FEB budget value(which is value from above after commit) for calculation...
now i need to write the script for every month on same calculation...when the calculation formula is change...i need to change the script for 12 time....
it may also have condition the budget is start from 2010.MARCH to 2011.FEB is depend on the property user set in dimension category. There is a property call "FIRSTPLANMONTH" = 2010.JAN which indicate the first month for the budget.
is there any way to loop through this script for 12 times to calculate the budget base on "FIRSTPLANMONTH" and last six month formula....
thanks...Hi,
I have created a script in sql server that updates the system parameters on a daily basis. It produces a maxl script. I am not sure how to automate it any other way.
Thanks,
Nathan -
Error: ORA-01847: day of month must be between 1 and last day of month
Hi,
I am getting this ORA-01847: day of month must be between 1 and last day of month type of error but I have checked my data all are correct.
I am inserting the data in the merge query. It is giving the above error.
but when i insert the data like that
insert into dt(start_date) select TO_DATE (tariff_start_date, 'DD/MM/RRRR') from ext_zpp0a871;
It does not give any error.
Please find the below code
DECLARE
l_sv_error_msg VARCHAR2 (1000);
BEGIN
FOR i IN (SELECT condition_type, sales_org, division_channel, division,
price_list, ean_upc, amount, unit_of_measure1,
tariff_start_date, tariff_end_date
FROM ext_zpp0a871--This is external table
WHERE condition_type = 'ZPP0' AND ROWNUM < 200)
LOOP
BEGIN
MERGE INTO sap_tariff st
USING (SELECT i.price_list pl, i.ean_upc upc,
TO_DATE (i.tariff_start_date, 'DD/MM/RRRR') tsd,
TO_DATE (i.tariff_end_date, 'DD/MM/RRRR') ted
FROM DUAL) du
ON (st.prod_ean_cuni = du.upc
AND st.pricelist = du.pl
AND st.tariff_start_date = du.tsd
AND st.tariff_end_date = du.ted)
WHEN MATCHED THEN
UPDATE
SET st.condition_type = i.condition_type,
st.sales_org = i.sales_org,
st.division_channel = i.division_channel,
st.division = i.division,
st.amount =
TO_NUMBER (REPLACE (REPLACE (i.amount, '.', NULL),
st.uom = i.unit_of_measure1
WHEN NOT MATCHED THEN
INSERT (condition_type, sales_org, division_channel, division,
pricelist, prod_ean_cuni, amount, uom,
tariff_start_date, tariff_end_date)
VALUES (i.condition_type, i.sales_org, i.division_channel,
i.division, i.price_list, i.ean_upc,
TO_NUMBER (REPLACE (REPLACE (i.amount, '.', NULL),
i.unit_of_measure1,
TO_DATE (i.tariff_start_date, 'DD/MM/RRRR'),
TO_DATE (i.tariff_end_date, 'DD/MM/RRRR'));
/*INSERT INTO sap_tariff
(condition_type, sales_org, division_channel,
division, pricelist, prod_ean_cuni,
amount,
uom,
tariff_start_date,
tariff_end_date
VALUES (i.condition_type, i.sales_org, i.division_channel,
i.division, i.price_list, i.ean_upc,
TO_NUMBER (REPLACE (REPLACE (i.amount, '.', NULL),
i.unit_of_measure1,
TO_DATE (i.tariff_start_date, 'DD/MM/RRRR'),
TO_DATE (i.tariff_end_date, 'DD/MM/RRRR')
EXCEPTION
WHEN DUP_VAL_ON_INDEX
THEN
UPDATE sap_tariff
SET condition_type = i.condition_type,
sales_org = i.sales_org,
division_channel = i.division_channel,
division = i.division,
amount =
TO_NUMBER (REPLACE (REPLACE (i.amount, '.', NULL),
uom = i.unit_of_measure1;
WHEN OTHERS
THEN
l_sv_error_msg := SQLERRM (SQLCODE);
INSERT INTO sap_tariff_log
(date_of_load, condition_type, sales_org,
division_channel, division, price_list,
prod_ean_cuni, amount, uom,
tariff_start_date, tariff_end_date,
rejection_reason
VALUES (SYSDATE, i.condition_type, i.sales_org,
i.division_channel, i.division, i.price_list,
i.ean_upc, i.amount, i.unit_of_measure1,
i.tariff_start_date, i.tariff_end_date,
l_sv_error_msg
END;
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
l_sv_error_msg := SQLERRM (SQLCODE);
neo_pro_log ('Others Error', l_sv_error_msg);
END;user13400510 wrote:
but when i insert the data like that
insert into dt(start_date) select TO_DATE (tariff_start_date, 'DD/MM/RRRR') from ext_zpp0a871;
It does not give any error.Maybe the error is on tariff_end_date instead of tariff_start_date ?
What are the datatypes of tariff_start_date and tariff_end_date ? If they are already dates, and you to_date them (and depending on what your nls_date_xxxxx params are) you can have such errors :SQL> sho parameter nls_date_format
NAME_COL_PLUS_SHOW_PARAM TYPE VALUE_COL_PLUS_SHOW_PARAM
nls_date_format string DD/MM/YYYY
SQL> select to_date(sysdate,'Day dd Mon RRRR') from dual;
select to_date(sysdate,'Day dd Mon RRRR') from dual
ERROR at line 1:
ORA-01846: not a valid day of the week
SQL> select to_date(sysdate,'hh24:mi:ss dd/mm/rrrr') from dual;
select to_date(sysdate,'hh24:mi:ss dd/mm/rrrr') from dual
ERROR at line 1:
ORA-01850: hour must be between 0 and 23 -
ORA-01847: day of month must be between 1 and last day of month error
Hi All
When i run the following code i'm getting the error:ORA-01847: day of month must be between 1 and last day of month error
SELECT t2.owner_cat,
t1.owner_id,
stock_id,
Sum(received_amount) received_amount,
Sum(curr_amount) curr_amount,
Sum(used_amount) used_amount,
To_char(Add_months(date_work,6),'YYYY') date_work
FROM (SELECT owner_id_to owner_id,
stock_id_to stock_id,
Sum(full_amount) received_amount,
0 curr_amount,
0 used_amount,
To_char(0) date_work
FROM dw_wms_mat_transfer
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id_to,
stock_id_to
UNION ALL
SELECT owner_id,
stock_id,
0 received_amount,
Sum(curr_amount) curr_amount,
0 used_amount,
To_char(0) date_work
FROM dw_wms_mat_inv
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id,
stock_id
UNION ALL
SELECT t2.owner_id,
t1.stock_id,
0 received_amt,
0 curr_amt,
Sum(amount) used_amt,
To_char(Add_months(date_work,6),'YYYY') date_work
FROM dw_wms_wo_mat_dc t1,
(SELECT owner_id,
stock_id
FROM dw_wms_mat_inv
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id,
stock_id) t2
WHERE t1.stock_id = t2.stock_id
GROUP BY t2.owner_id,
t1.stock_id,
To_char(Add_months(date_work,6),'YYYY')) t1,
dw_wms_setup_owner t2
WHERE t1.owner_id = t2.owner_id
GROUP BY t2.owner_cat,
t1.owner_id,
stock_id,
To_char(Add_months(date_work,6),'YYYY')
But when i just run the inner query:
(SELECT owner_id_to owner_id,
stock_id_to stock_id,
Sum(full_amount) received_amount,
0 curr_amount,
0 used_amount,
To_char(0) date_work
FROM dw_wms_mat_transfer
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id_to,
stock_id_to
UNION ALL
SELECT owner_id,
stock_id,
0 received_amount,
Sum(curr_amount) curr_amount,
0 used_amount,
To_char(0) date_work
FROM dw_wms_mat_inv
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id,
stock_id
UNION ALL
SELECT t2.owner_id,
t1.stock_id,
0 received_amt,
0 curr_amt,
Sum(amount) used_amt,
To_char(Add_months(date_work,6),'YYYY') date_work
FROM dw_wms_wo_mat_dc t1,
(SELECT owner_id,
stock_id
FROM dw_wms_mat_inv
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id,
stock_id) t2
WHERE t1.stock_id = t2.stock_id
GROUP BY t2.owner_id,
t1.stock_id,
To_char(Add_months(date_work,6),'YYYY'))
I'm not getting that error, any help please?Hi,
Like Anuraq already explained, you need to keep in mind that when you apply a to_char, you've turned your DATE datatype into a STRING and by doing that you've lost the ability to use the add_months function again in your outer query.
Using a simplified example, extracted from your example:
MHO%xe> select to_char(add_months(date_work, 6), 'yyyy') date_work
2 from ( select to_char(0) date_work
3 from dual
4 union all
5 select to_char(0) date_work
6 from dual
7 union all
8 select to_char(add_months(sysdate, 6), 'yyyy') date_work
9 from dual
10 );
select to_char(add_months(date_work, 6), 'yyyy') date_work
FOUT in regel 1:
.ORA-01847: day of month must be between 1 and last day of monthHowever, you should either do something like:
MHO%xe> select nvl(to_char(add_months(date_work, 12), 'yyyy'), '0') date_work
2 from ( select to_date(null) date_work
3 from dual
4 union all
5 select to_date(null) date_work
6 from dual
7 union all
8 select sysdate date_work
9 from dual
10 );
DATE
0
0
2010or (less clear, more confusing):
MHO%xe> select nvl(to_char(add_months(date_work, 6), 'yyyy'), '0') date_work
2 from ( select to_date(null) date_work
3 from dual
4 union all
5 select to_date(null) date_work
6 from dual
7 union all
8 select add_months(sysdate, 6) date_work
9 from dual
10 );
DATE
0
0
2010It's not clear to me why you're using add_months twice (inner + outer query) in your original example.
As you can see you can get the same results using it only once in your outer query. -
Ora-01847 day of month between 1 and last date of month coming in my query
i m executing simple query but it is not working plz do help
select *
from sgvf_tree_nodes_vw
where to_date(node_attr9_val, 'dd/mm/yyyy') between
to_date('01/01/2010', 'dd/mm/yyyy') and
to_date('31/12/2010', 'dd/mm/yyyy')
gives : Ora-01847 day of month should be between 1 and last date of monthHi,
Check the date format's once
SQL> drop table demo;
Table dropped.
SQL> create table demo(val number, todate varchar2(12));
Table created.
SQL> insert into demo values(1,'04/11/2008');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from demo;
VAL TODATE
1 04/11/2008
SQL> select sysdate from dual;
SYSDATE
03-FEB-11
SQL> insert into demo values(1,'04/11/2010');
1 row created.
SQL> commit;
Commit complete.
SQL> select *
2 from demo
3 where to_date(todate,'dd/mm/yyyy') between to_date('01/01/2010', 'dd/mm/yyyy') and to_date('31/12/2010', 'dd/m
m/yyyy');
VAL TODATE
1 04/11/2010- Pavan Kumar N -
Date must be between year 1 and year 9999 - error message
I am receiving the following error message "Dates must be between year 1 and year 9999". The highest value in the next date value in the DB is 12/31/9999. The parameters being entered are 01/1900 and 12/9999. The following formula is the cause of the error:
EvaluateAfter ({@Start Date});
Global DateVar EndDate;
Global StringVar strEndMonth:=Mid({?End Month/Year} ,1, 2) ;
Global StringVar strEndYear:=Mid({?End Month/Year} ,4, 4) ;
Global NumberVar nNextMonth:=CDbl (strEndMonth) + 1 ;
Global StringVar strEndDay:=ToText(Day(DateSerial (CDbl (strEndYear) , nNextMonth, 1-1) ) , 0) ;
Global StringVar strEndDate:=Right ("00" + strEndMonth, 2 ) + "/"Right ("00"strEndDay,2) +"/" +strEndYear ;
Global DateVar EndDate:=CDate(strEndDate) ;
The bolded section is the section of the formula highlighted in Crystal. I've determined if the user enters 11/9999 as the end date instead of 12/9999 the report runs fine. Is this a problem with the formula or a limitation in Crystal or little of both? I don't understand what the formula is doing but at the end of the year it looks like it counts forward to January and then back to December and obviously 9999 is the highest year possible so the attempt to go a month ahead tanks. Is there a change I can make in the formula to avoid this error?The error lies in the formula.
Global NumberVar nNextMonth:=CDbl (strEndMonth) + 1 ;
When you enter 12/9999 it adds 1 to the month of 12 giving it 13.
Global StringVar strEndDay:=ToText(Day(DateSerial (CDbl (strEndYear) , nNextMonth, 1-1)) , 0) ;
This calculates the last day of the month. Since from above the variable nNextMonth is 13, it tries to calculate 9999, 13, 1-1 which is invalid since there is no 13th month in any year.
Make this change and it should work fine.
Global DateVar EndDate;
Global StringVar strEndMonth:=Mid({?End Month/Year} ,1, 2) ;
Global StringVar strEndYear:=Mid({?End Month/Year} ,4, 4) ;
Global NumberVar nNextMonth:=if CDbl (strEndMonth) = 12 then CDbl (strEndMonth) else CDbl (strEndMonth)+ 1 ;
Global StringVar strEndDay:=ToText(Day(DateSerial (CDbl (strEndYear) , nNextMonth,
if CDbl (strEndMonth) = 12 then 31 else 1-1)) , 0) ;
Global StringVar strEndDate:=Right ("00" + strEndMonth, 2 ) + "/"+Right ("00"+strEndDay,2) +"/" +strEndYear ;
Global DateVar EndDate:=CDate(strEndDate) ;
Edited by: Sanjay Kodidine on Apr 7, 2009 11:19 AM -
ORA-1850: hor must be between 0 and 23 error
Hi All
i have the following table for creating and inserting i included only two fileds as these are the fields that i'm getting errors on.
WITH sample_data AS
SELECT '50709' AS start_date, '2400' AS start_time FROM dual UNION ALL
SELECT '082510', '0000' FROM dual
SELECT *
FROM sample_data
;DATA:
START_DATE START_TIME
50709 2400
082510 0000And now when i run the query against the table:
SELECT direction, car_count_pos, truck_count_pos,
(car_count_pos + 2 * (truck_count_pos)) AS adjusted, car_count_neg,
truck_count_neg,
(car_count_neg + 2 * (truck_count_neg)) AS adjusted_neg,
TO_DATE (start_date, 'MMDDYY') AS start_date,
TO_DATE (end_date, 'MMDDYY') AS end_date,
ROUND (TO_CHAR (TO_DATE (LPAD (start_time, 4, '0'), 'HH24MI'),
'HH24.MI'
) AS start_time,
start_time,
(TO_DATE (end_date, 'MMDDYY') - TO_DATE (start_date, 'MMDDYY')
) AS days
FROM (SELECT (CASE
WHEN t1.direction = '1'
THEN ( COUNT (t1.bin_1_data)
+ COUNT (t1.bin_2_data)
+ COUNT (t1.bin_3_data) * 0.981 * 1.019
ELSE NULL
END
) AS car_count_pos,
t1.direction,
(CASE
WHEN t1.direction = '1'
THEN ( COUNT (t1.bin_4_data)
+ COUNT (t1.bin_5_data)
+ COUNT (t1.bin_6_data)
+ COUNT (t1.bin_7_data)
+ COUNT (t1.bin_8_data)
+ COUNT (t1.bin_9_data)
+ COUNT (t1.bin_10_data)
+ COUNT (t1.bin_11_data)
+ COUNT (t1.bin_12_data)
+ COUNT (t1.bin_13_data)
+ COUNT (t1.bin_14_data)
+ COUNT (t1.bin_15_data) * 0.981 * 1.019
ELSE NULL
END
) AS truck_count_pos,
(CASE
WHEN t1.direction = '3'
THEN ( COUNT (t1.bin_1_data)
+ COUNT (t1.bin_2_data)
+ COUNT (t1.bin_3_data) * 0.981 * 1.019
ELSE NULL
END
) AS car_count_neg,
(CASE
WHEN t1.direction = '3'
THEN ( COUNT (t1.bin_4_data)
+ COUNT (t1.bin_5_data)
+ COUNT (t1.bin_6_data)
+ COUNT (t1.bin_7_data)
+ COUNT (t1.bin_8_data)
+ COUNT (t1.bin_9_data)
+ COUNT (t1.bin_10_data)
+ COUNT (t1.bin_11_data)
+ COUNT (t1.bin_12_data)
+ COUNT (t1.bin_13_data)
+ COUNT (t1.bin_14_data)
+ COUNT (t1.bin_15_data) * 0.981 * 1.019
ELSE NULL
END
) AS truck_count_neg,
t2.start_date, t2.start_time, t2.end_date, t2.end_time
FROM bin_data t1, traffic_sample t2
WHERE t1.traffic_sample_id = t2.traffic_sample_id
GROUP BY t1.direction,
t2.start_date,
t2.start_time,
t2.end_date,
t2.end_time)
WHERE direction IN ('1', '3')
GROUP BY TO_DATE (start_date, 'MMDDYY'),
direction,
car_count_pos,
truck_count_pos,
(car_count_pos + 2 * (truck_count_pos)),
truck_count_neg,
(car_count_neg + 2 * (truck_count_neg)),
TO_DATE (end_date, 'MMDDYY'),
ROUND (TO_CHAR (TO_DATE (LPAD (start_time, 4, '0'), 'HH24MI'),
'HH24.MI'
start_time,
car_count_negI'm getting the error
ORA-1850: Hour must be between 0 and 23
But as you see there is a value 2400 in the table is there any way to get around this? please need help.
Thanks
Edited by: thinkingeye on Aug 26, 2010 8:42 AMThanks AP but i came up with something different which i guess sserved the same purpose i used the DECODE fucntion in the INNER query.
SELECT direction, car_count_pos, truck_count_pos,
(car_count_pos + 2 * (truck_count_pos)) AS adjusted, car_count_neg,
truck_count_neg,
(car_count_neg + 2 * (truck_count_neg)) AS adjusted_neg,
TO_DATE (start_date, 'MMDDYY') AS start_date,
TO_DATE (end_date, 'MMDDYY') AS end_date,
ROUND (TO_CHAR (TO_DATE (LPAD (start_time, 4, '0'), 'HH24MI'),
'HH24.MI'
) AS start_time,
ROUND (TO_CHAR (TO_DATE (LPAD (end_time, 4, '0'), 'HH24MI'),
'HH24.MI'
) AS end_time,
start_time,
(TO_DATE (end_date, 'MMDDYY') - TO_DATE (start_date, 'MMDDYY')
) AS days,
CITY,COUNTY,LOCATION,ROUTE_NBR,ROUTE_TYPE
FROM (SELECT (CASE
WHEN t1.direction = '1'
THEN ( COUNT (t1.bin_1_data)
+ COUNT (t1.bin_2_data)
+ COUNT (t1.bin_3_data) * 0.981 * 1.019
ELSE NULL
END
) AS car_count_pos,
t1.direction,
(CASE
WHEN t1.direction = '1'
THEN ( COUNT (t1.bin_4_data)
+ COUNT (t1.bin_5_data)
+ COUNT (t1.bin_6_data)
+ COUNT (t1.bin_7_data)
+ COUNT (t1.bin_8_data)
+ COUNT (t1.bin_9_data)
+ COUNT (t1.bin_10_data)
+ COUNT (t1.bin_11_data)
+ COUNT (t1.bin_12_data)
+ COUNT (t1.bin_13_data)
+ COUNT (t1.bin_14_data)
+ COUNT (t1.bin_15_data) * 0.981 * 1.019
ELSE NULL
END
) AS truck_count_pos,
(CASE
WHEN t1.direction = '3'
THEN ( COUNT (t1.bin_1_data)
+ COUNT (t1.bin_2_data)
+ COUNT (t1.bin_3_data) * 0.981 * 1.019
ELSE NULL
END
) AS car_count_neg,
(CASE
WHEN t1.direction = '3'
THEN ( COUNT (t1.bin_4_data)
+ COUNT (t1.bin_5_data)
+ COUNT (t1.bin_6_data)
+ COUNT (t1.bin_7_data)
+ COUNT (t1.bin_8_data)
+ COUNT (t1.bin_9_data)
+ COUNT (t1.bin_10_data)
+ COUNT (t1.bin_11_data)
+ COUNT (t1.bin_12_data)
+ COUNT (t1.bin_13_data)
+ COUNT (t1.bin_14_data)
+ COUNT (t1.bin_15_data) * 0.981 * 1.019
ELSE NULL
END
) AS truck_count_neg,
t2.start_date, t2.start_time, t2.end_date,*decode(t2.END_TIME,2400,'2359',t2.end_time) as end_time*,t3.CITY, t3.COUNTY,t3.LOCATION,t3.ROUTE_NBR, t3.ROUTE_TYPE
FROM bin_data t1, traffic_sample t2,location_details t3
WHERE t1.traffic_sample_id = t2.traffic_sample_id
and t2.TRAFFIC_SAMPLE_ID=t3.TRAFFIC_SAMPLE_ID
GROUP BY t1.direction,
t2.start_date,
t2.start_time,
t2.end_date,
t2.end_time,
t3.CITY, t3.COUNTY,t3.LOCATION,t3.ROUTE_NBR, t3.ROUTE_TYPE)
WHERE direction IN ('1', '3')
GROUP BY TO_DATE (start_date, 'MMDDYY'),
direction,
car_count_pos,
truck_count_pos,
(car_count_pos + 2 * (truck_count_pos)),
truck_count_neg,
(car_count_neg + 2 * (truck_count_neg)),
TO_DATE (end_date, 'MMDDYY'),
ROUND (TO_CHAR (TO_DATE (LPAD (start_time, 4, '0'), 'HH24MI'),
'HH24.MI'
start_time,
car_count_neg,
end_time,
CITY,COUNTY,LOCATION,ROUTE_NBR,ROUTE_TYPE -
SQL select Statement -first day and last day of the month - 1 year from now
Hi,
I need to write a SQL to get the dates in between first day and last day of the month one year from now.
SELECT last_day(add_months(sysdate,12)) as lastday from dual
What could be the Query to get the first day of the month one year from now..
ie ..Sysdate - 3-DEC-2009
Result - 1-DEC-2010
thank youHi,
You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
SELECT TRUNC ( ADD_MONTHS ( SYSDATE
, 12
, 'MONTH'
) AS first_of_month
FROM dual
;The DATE returned will be in the same month, year, quearter, ... as the first argument.
\We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
For example, to find all appointment_dates in the current month next year:
SELECT *
FROM appointments
WHERE appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
AND appointment_date < TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future.
Maybe you are looking for
-
SAP CC 2.0 Problem with Core Tool and License
We have an instace of Sap Convergent Charging that has been running until the other day. Since yesterday we are retrieving the an error if we execute the Core tool : Once we execute the core_tool.bat application we insert the correct user and passwor
-
How to restrict copies printed in PDF?
Hi, Is there any way to restrict the number of copies of a PDF printed? Is there any way to restrict the printing of a PDF so that it can't be printed after a certain date? Jane
-
How can i get my ringtones back on my iphone
How can i retrive my ringtones back on my iphone ,since i updated my iphone everything was deleted on my iphone
-
FCE plug ins for different USERs
I searched for an answer but couldn't find one. My dilemna - When I'm in the ADMIN/main user environment I have access to all my FCE 3.5HD plug-ins. When I switch to USER1 enviroment, only a few plug-ins appear. I tried to put the FCE plug-ins from t
-
Help!! N85 with no call sound
Hi, my N85 has all of a sudden ceased to have sound when I make a call or someone calls me BUT, if I use the loudspeaker, it works. I took it back to the store I bought it and a salesman had the same problem and Nokia told him to update the firmware.