How to convert Date type
I have a JSP to read the date value and use it to update the corresponding column in the table. In the JSP, the data type returned from request.getParameter("hiredate") is java.util.Date. Unfortunately, the CachedRowSet requires the java.sql.Date type. How can I convert the java.util.Date type to java.sql.Date type? Please advise,thanks.
SK
SK,
This is how I do it:
java.util.Date utilDate = new java.util.Date();
long millis = utilDate.getTime();
java.sql.Date sqlDate = new java.sql.Date(millis);Good Luck,
Avi.
Similar Messages
-
How to convert data type while using @variable function
Hi Gurus,
I have a query.
i have created a Derived Table and the statement is given below.
select 1 as SENSITIVITY_LEVEL,1 as SUBSENSITIVITY,@variable('US_T') as NITEMS, ...........
here in @variable('US_T') "US_T" is hard coded value. I want to change to data type of hard coded value as numeric or integer
i am using sap BI 4.0 universe design tool.
Thanks in Advance.
Regards,
JeetHi Jeet,
Since it is text you can't convert into number.
Can you please let mw know the exact requriement of yours?
why you need this
Thanks,
Swapnil -
How to Convert Data types here
Hi All,
My stored proc is as below,
create or replace procedure proc_sec_synch (
Begin
FOR sec_Update in (
Select
SsM_ID ,
CYCLE_DATE ,
TARGET_TABLE ,
COLUMN_NAME ,
NEW_DATA ,
COLUMN_TYPE from PM_OWN.test_synch order by target_table
Loop
*'Update' || sec_Update.target_table ||' dest SET dest.' ||sec_Update.column_name||' =*
*(select src.new_data from pm_own.test_synch src where src.ssm_id = '||sec_Update.target_table||'.ssm_id)'*
END Loop;
END proc_sec_synch;
actually I'm updating different tables using one table. the one table consists all the data like target table name and column name and the values also.
in the above query, the data type of value what I'm retreiving from pm_own.test_synch is different from target table column datatype.
so how could I change the type of retreiving value to the destination table column data type.
help me.Here is the answer...
Actuallly I have two databases which I need to synch 2nd database using first database, synch in the not entore database but only few tables and only few columns and that too on specific where condotions. so I made so many queries and retreiving data into temp tables and then updating into target tables,
instead of above what I'm trying is I have created a stagiing table where I'll update the data (by using all above seelect queries) and update the target tables in one shot withoput using temp tables.
Bottom line is:
I need to get the report for the data that is getting updated daily before updating.
and before updating I should have previllage to decide whether to update or not..?
Cheers,
Naresh -
How to Convert Data type from CLOB to LONG
Hi all
We changed one Long Data type column to CLOB
We need to revert back to Long Data type,
we changed the Data type from Long to CLOB
Can we change back to Long Again
we use oracle 10g Rel 2 on Hp-Unix
thanks all in Advance
Edited by: jrDba - atm on Apr 6, 2009 4:45 AMHi Satish
thanks a alot for the Info'
Can you please provide the
Notes MOS note 437021.1 for this purpose
thanks a lot -
Error converting data type nvarchar to numeric 'witholding tax' (OWHT)
Hi Guys.
After I have upgraded my clients 2007 PL 30 database to 8.81 PL05, and running a repair to fix inconsistincies, I am receiveing some error when opening any sales documents.
It takes place when I open a sales document, or browse previous docs. When browsing previous docs, it onlly happens on some of them.
I also receive a different error when viewing sales orders: Error converting data type nvarchar to numeric (CRD2).
Any ideas how to fix it?
It does not limit me from processing and using the rest of the functionality. All calculations with queries in the docs are still working.
Thanks.Hi,
Please check Note No. : 1402855 and see if the same applied to the issue mentioned by you.
Kind Regards,
Jitin
SAP Business One Forum Team -
Im getting an error when running a procedure that includes this code.
I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
DECLARE @retval AS DECIMAL(12,2)
DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
DECLARE @sqlcmd AS NVARCHAR(150)
DECLARE @paramdef NVARCHAR(150)
SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
--default
SET @retval = 0.0;
EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
SELECT @retval
DECLARE @return_value DECIMAL(12,2)
EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
@SpreadKey = 1,
@MonthNumber = 4
SELECT 'Return Value' = @return_value
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
the shoe size, the phone number or something else at run time of this entity.
In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point.
Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity.
Do you know that SQL is a declarative language? This family of languages does not use local variables!
Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.
Think about how silly this is:
SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental.
We need to see the DDL so we can re-write this mess. Want to fix it or not?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Crystal Data Conversion Issue (Error converting data type varchar to datetime)
Hi,
I can run stored procedure without error in SQL Server using my personal credentials as well as database credentials.
I can also run Crystal Report after connecting to Stored procedure without error on my desktop using my personal credentials as well as database credentials.
But when I upload the crystal report in BOBJDEV and when I run using database credentials report fails saying that "Error in File ~tmp1d1480b8e70fd90.rpt: Unable to connect: incorrect log on parameters. Details: [Database Vendor Code: 18456 ]" but I can run the crystal report successfully on BOBJDEV using my personal credentials.
I googled (Data Conversion Error Message) about this issue & lot of people asked to do "Verify Database" in Crystal Report. So I did that, but when I do it I am getting a error message like this:
Error converting data type varchar to datetime.
Where do you think the error might be occurring? Did anyone faced this kind of issue before? If so, how to resolve it?
(FYI, I am using Crystal Reports 2008, & for stored procedure I have used SSMS 2012 )
Please help me with this issue.
Thanks & Regards.
Naveen.hello Naveen,
since the report works fine in the cr designer / desktop, we need to figure out where you should post this question.
by bobjdev do you mean businessobjects enterprise or crystal reports server? if so please post this question to the bi platform space.
-jamie -
How to convert date format to MM/DD/YYYY
Hi,
How to convert date format to MM/DD/YYYY.
Thanks,
Senthilhi,
tri with this function module
data :l_date(10) type c
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
DATE_INTERNAL = SY-DATUM
IMPORTING
DATE_EXTERNAL = l_date.
this function module converts date from 20050601 to external format which is specified in user profile
cheers,
sasi -
hi
How to convert date data type to number data type:
Using to_char and to_number
Thanks
Edited by: josh1612 on Nov 17, 2008 12:37 AMAnother approach can be ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.00
satyaki>
satyaki>create table a_a(dt date)
2 ;
Table created.
Elapsed: 00:00:00.01
satyaki>
satyaki>
satyaki>insert into a_a values(sysdate)
2 ;
1 row created.
Elapsed: 00:00:00.00
satyaki>
satyaki>commit;
Commit complete.
Elapsed: 00:00:00.00
satyaki>
satyaki>select * from a_a;
DT
17-NOV-08
Elapsed: 00:00:00.00
satyaki>
satyaki>
satyaki>select cast(to_char(dt,'ddmmyyyy') as number(10)) res
2 from a_a;
RES
17112008
Elapsed: 00:00:00.00
satyaki>Regards.
Satyaki De. -
How to convert DATE variable to CHAR variable
dear all,
How to convert DATE variable to CHAR variable
thanqDepending on your final goal here are 2 options.
DATA: datein TYPE d.
DATA: dateout(10) TYPE c.
DATA: dateout2(8) TYPE c.
datein = sy-datum.
WRITE datein TO dateout MM/DD/YYYY.
dateout2 = datein.
WRITE:/ datein, dateout, dateout2.
and the output
05022008 05/02/2008 20080502 -
Problem with converting data types
Hi Experts,
I am stuck up with a little problem, i need your help
i am converting all the data types to CHAR but i am not getting the expected data out.........
My code is as below...where do i go wrong...
LOOP AT <T_ITAB> ASSIGNING <FIELD>.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <FIELD> TO <RECORD>.
IF SY-SUBRC = 0.
LV_FIELD = <RECORD>.
N = STRLEN( LV_FIELD ).
IF N = '8'.
IF LV_FIELD IS NOT INITIAL.
LV_DATE = LV_FIELD.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = LV_DATE
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 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.
IF SY-SUBRC EQ 0.
CONCATENATE LV_FIELD+6(2) LV_FIELD+4(2) LV_FIELD+0(4) INTO LV_FIELD SEPARATED BY '.'.
ENDIF.
ENDIF.
ENDIF.
IF LV_RECORD IS INITIAL.
LV_RECORD = LV_FIELD.
ELSE.
CONCATENATE LV_RECORD LV_FIELD INTO LV_RECORD SEPARATED BY ' * '.
ENDIF.
ELSE.
EXIT." DO
ENDIF.
ENDDO.
APPEND LV_RECORD TO LT_OUTPUT.
CLEAR LV_RECORD.
ENDLOOP.
THE TABLE LT_OUTPUT LIKE THENV(CHAR 255)
My output looks some thing like this:
04 36876 15.09.2011 39600 1999
06 36960 15.09.2011 39600 2632
07 36874 15.09.2011 39541 9232
My expected output
04 36.876 15.09.2011 39.600 1.999
06 36.960 15.09.2011 39.600 2.632
07 36.874 15.09.2011 39.541 9.232
Regards
samAt run time you can see all the data........ like what i have shown...
but if you clearly see, DATE will be in the internal format..but if you print it, it will be in dd:mm:yyyy
can you suggest me if i have a dynamic field symbol (table data) ,,,, How can i convert data types dynamically..
if it is a static internal table i am achieving with WRITE TO statement.....but i have huge data in field symbols...
Instead of all these , please specify the exact problem your are facing . What is it with date field ? . In SAP while printing the internal format will be converted to external. What is your requirement with this date field?
My output looks some thing like this:
04 36876 15.09.2011 39600 1999
06 36960 15.09.2011 39600 2632
07 36874 15.09.2011 39541 9232
My expected output
04 36.876 15.09.2011 39.600 1.999
06 36.960 15.09.2011 39.600 2.632
07 36.874 15.09.2011 39.541 9.232
I dont see any problems mentioned in your date field. Both your actual and expected outputs reflects the same in date field.
In SCN you will only get solutions if your question is precise.
Kesav -
How to get data type of variable in program..
Hi ABAP Guru.
I need to know how to get data type of variable or any structure field.. because I got short dump when use command REPLACE ALL OCCURANCE ... with variable/structure field that has data type I or P, I think it should be used with data type CHAR only, So I need to check the data type first.
Please give me your advice
Thank you all.
Nattapash C.data : v_value type i,
v_char(10) type c.
v_value = 10.
move v_value to v_char.
REPLACE ALL OCCURRENCES of '#' from v_char....
Best regards,
Prashant -
How to change data type of attribute in caf
hi.
this is my problem.
i been added a attribute in an entity service called emloyee. named "Birthday", use the data type "com.sap.caf.core.date".
when i tried modify the entity service, i hit exception about "DST Daylight Saving Time".
because of DST, the date will add an hour such like "1957/04/01 00:00:00.0" to "1957/04/01 01:00:00.0", and com.sap.caf.core.date will throw an exception.
is anyone had same problem like me?
how to fixed it(if passable)?
and, how to change data type?
thanks.Hi Sruthi,
all you need to do on this is open the report go to the parameters, select the parameter that you wish to change and click "Edit". This will allow you to change thefield to a date rather than a date time.
Regards,
Noel -
How to convert date dd.mm.yyyy TO Month ddth YYYY?
hi friends,
how to convert date into this format.
ex:
date : 04.11.2008
has to convert as
October 04th, 2008
th has to be set SUPERSCRIPT.
Plz any helps....
Regards,
Shankar.check this..FM
CONVERT_DATE_TO_EXTERNAL
or we can do this using split or concatenate functions like below
*CALCULATING THE MONTH FOR THE BODY OF THE EMAIL MSG
IF GD_EBODY_BB = '01' .
GD_EBODY_BB = 'January' .
ELSEIF GD_EBODY_BB = '02' .
GD_EBODY_BB = 'February' .
ELSEIF GD_EBODY_BB = '03' .
GD_EBODY_BB = 'March' .
ELSEIF GD_EBODY_BB = '04' .
GD_EBODY_BB = 'April' .
ELSEIF GD_EBODY_BB = '05' .
GD_EBODY_BB = 'May' .
ELSEIF GD_EBODY_BB = '06' .
GD_EBODY_BB = 'June' .
ELSEIF GD_EBODY_BB = '07' .
GD_EBODY_BB = 'July' .
ELSEIF GD_EBODY_BB = '08' .
GD_EBODY_BB = 'August' .
ELSEIF GD_EBODY_BB = '09' .
GD_EBODY_BB = 'September' .
ELSEIF GD_EBODY_BB = '10' .
GD_EBODY_BB = 'October' .
ELSEIF GD_EBODY_BB = '11' .
GD_EBODY_BB = 'November' .
ELSEIF GD_EBODY_BB = '12' .
GD_EBODY_BB = 'December' .
ENDIF .
*ATTACHMENT SUBJECT LINE MODIFICATION
IF GD_EBODY_CC = '01'.
CONCATENATE GD_EBODY_CC 'st' INTO GD_EBODY_CC .
ELSEIF GD_EBODY_CC = '02' .
CONCATENATE GD_EBODY_CC 'nd' INTO GD_EBODY_CC .
ELSEIF GD_EBODY_CC = '03' .
CONCATENATE GD_EBODY_CC 'rd' INTO GD_EBODY_CC .
ELSEIF GD_EBODY_CC = '31'.
CONCATENATE GD_EBODY_CC 'st' INTO GD_EBODY_CC .
ELSEIF GD_EBODY_CC = '21'.
CONCATENATE GD_EBODY_CC 'st' INTO GD_EBODY_CC .
ELSE .
CONCATENATE GD_EBODY_CC 'th' INTO GD_EBODY_CC .
ENDIF .
regards
ansumesh
Edited by: Ansumesh Kumar Samal on Nov 4, 2008 9:02 AM -
How to Convert Date (DD.MM.YYYY) to be just DD
Hi experts,
I have no idea how to convert Date format (DDMMYYYY) to be just DD.
Example:
I have date: 31.10.2009
now i just want to show in report as 31.
I just known if we just want to show month only, we could use the 0CALMONTH2. but how if i need the day only?
Are there any way, either in query (BEx) or modeling (Routine/Formula in Update Rules or Transfer Rules) which could fulfill the requirement?
Many thanks..
Warm Regards,
TikaHi,
go through the link below and modify according to your requirement
Date conversion from YYYYMMDD to DD.MM.YYYY
Regards,
Marasa.
Maybe you are looking for
-
I want to add a download action for dxf files so they open in Autodesk trueview. The steps described here (http://support.mozilla.com/en-US/kb/Managing%20file%20types#w_adding-download-actions) say to click on a link for the filetype you want to add
-
Text disappears behind keyboard in imessage
SInce IOS8 I have a problem with Imessage in landscape mode. The last texts disappears behind the keyboard.
-
Best practice for passing parameters to a Timer event handler?
The code hinting is suggesting that I use a Timer object rather than setTimeout or setInterval, however I need to pass a parameter to the timer handler. What is the best practice for doing this? + Subclass Timer? + Subclass TimerEvent? + Global varia
-
Why are there two versions of flash player on my laptop?
I'm running 64 bit Windows 7 Professional which seems to handle both 32 and 64 bit software. I use Firefox as my default browser and use MSIE only when I must. A Flash update failed so I checked the uninstall programs list thinking I'll just uninst
-
Can I use my iPad buyed app on my Macbook Pro?
Hi I just get a McBook Pro and I want to know if I have to pay again for all the apps that I bought before to my Ipad ... I would like to have in both device Thanks for any answer