Change format date TO_DATE(TRUNC(DBMS_RANDOM.VALUE...
Hi all...
I am trying dbms_random like this :
**Type data :
AAAA VARCHAR2(35)
BBBB VARCHAR2(6)
DDDD VARCHAR2(20)
E_DATE VARCHAR2(14)
**store procedur :
BEGIN
FOR X IN 0..3 LOOP
INSERT INTO TEST VALUES (
'AAAA--'|| dbms_random.string('X', 28),
'BBBB' || TO_CHAR (TRUNC(dbms_random.value(0,10))),
'CCCC--'|| dbms_random.string('X', 12),
TO_DATE(TRUNC(DBMS_RANDOM.VALUE(2455532,2455563+3)),'J')
END LOOP;
END;
Output :
AAAA BBBB DDDD E_DATE
AAAA--RTL2OWN8RVOMY1IUD93RP91RWOQA BBBB1 CCCC--JCWAXRO3TMP0 12-DEC-10
AAAA--629F3A4AIW5E4OHCDVFZ41SFB2U4 BBBB5 CCCC--DLAUZO511Y97 12-DEC-10
AAAA--XHKR95JISQRTRH54KNOQKDVUJ6QF BBBB6 CCCC--K7CHOT2KULNV 10-DEC-10
AAAA--7DRZ38SPRIN26HNA7VPQV9FKWCCQ BBBB7 CCCC--FXV3CCY3BWHY 09-DEC-10i want format E_DATE to DD-MM-YYYY without change type data and still use dbms_random...
Could you pls solve me out ?
Thank you
-newbie-pl/sql-
Hi,
Sorry, I'm not sure I uderstand the problem.
Are you getting the date correctly, but you want to store it in a VARCHAR2 column? That's not a very good idea: dates belong in DATE columns, but if you ever want to convert a DATE into a string, use TO_CHAR:
TO_CHAR ( TO_DATE ( TRUNC ( DBMS_RANDOM.VALUE (2455532, 2455563+3)
, 'J'
, 'DD-MM-YYYY'
)or equivalently:
TO_CHAR ( DATE '2010-12-01' + dbms_random.value (0, 34)
, 'DD-MM-YYYY'
)Since you're not displaying the hours, minutes or seconds, there's no point in using TRUNC just to set them to 00:00:00.
Edited by: Frank Kulash on Feb 9, 2011 10:32 PM
Similar Messages
-
hi,
who i can change format date in servidor ORACLE for all client?
Thank´sThe default format can be set by changing the NLS_DATE_FORMAT initialization parameter and restarting the database, alter system set nls_date_format = "YYYYMMDD" scope=spfile; and the database has to be shutdown and restarted to enforce the change. It might be alter database instead of alter system, I usually try the wrong one first.
But the setting can be overridden in the client setup or changed in a user session, there's no way to enforce a particular format on the client environment. -
Change format date for Calendar Prompt!!!
Hello there,
For a date prompt when I choose *"Calendar"* in my control, the default format shown by the calendar is d/mm/yyyy.
I want to save the value of my date prompt into a Presentation variable with the format yyyy-mm-dd. What conversion function can be used to achieve this?. In oracle the easiest way is TO_CHAR(dateHere,'YYYY-MM-DD') but when I apply this in the Edit Formula of the prompt it gives me an error.
I know the date format for a Calendar object can be changed in the configuration file, but I want to avoid this, because I might affect other users.
Please help.
Thanks
Edited by: PabloC2 on Feb 18, 2009 1:36 PMyes, I restarted presentation server and oc4j.
but has no effects.
date prompt has strange behaviour...
for Administrator user
in English locale
default format YYYY-MM-DD
after change date by calendar, it has M.D.YYYY format
in my locale
default format YYYY-MM-DD
after change date by calendar, it has YYYY.M.D format
for other users
in English locale
default format YYYY-MM-DD
after change date by calendar, it has YYYY.M.D format
in my locale
default format YYYY-MM-DD
after change date by calendar, it has YYYY.M.D format -
Hi
There is a table with column datatype is varchar2(11) with data like
21-DEC-2010
22-DEC-2010
23-DEC-2010
28-DEC-2010
29-DEC-2010
29-DEC-2010
28-DEC-2010
29-DEC-2010
01-DEC-2010
28-DEC-2010
29-DEC-2010How can I put data in format 'DD/MM/YYYY' I tried with
select TO_date(t.nota_data,'DD-MON-YYYY')
from tb_carga_fat_suma tBut show me error message:
ORA-01843: not a valid monthSQL> with t as (
2 select ('21-DEC-2010') str from dual union
3 select ('22-DEC-2010') from dual union
4 select ('23-DEC-2010') from dual union
5 select ('28-DEC-2010') from dual union
6 select ('29-DEC-2010') from dual union
7 select ('29-DEC-2010') from dual union
8 select ('28-DEC-2010') from dual union
9 select ('29-DEC-2010') from dual union
10 select ('01-DEC-2010') from dual union
11 select ('28-DEC-2010') from dual union
12 select ('29-DEC-2010') from dual
13 )
14 --
15 --
16 --
17 select str
18 , to_char(to_date(str, 'dd-MON-yyyy'), 'dd/mm/yyyy') new_str
19 from t
20 /
STR NEW_STR
01-DEC-2010 01/12/2010
21-DEC-2010 21/12/2010
22-DEC-2010 22/12/2010
23-DEC-2010 23/12/2010
28-DEC-2010 28/12/2010
29-DEC-2010 29/12/2010
6 rows selected. -
Change formatting dates with GREP
I am laying out a book with thusands of dates all formatted e.g 02-03-1913. I want to hange these to (eg) 2nd March 1913. I expected it to be a lengthy, staged, operation. But I cannot get GREP to recognise specific numbers (e.g. 02) If worked through logically I did think I could do it in stages. Can anyone help?
Hi,
Using Multi-Find/Change, 12 regex, 1 set. So, 1 click and done!
1/ Search: (0?)(\d+)-01-(\d{4})
Replace by: $2~Sjanuary~S$3
2/ Search: (0?)(\d+)-02-(\d{4})
Replace by: $2~Sfebruary~S$3
12/ Search: (0?)(\d+)-12-(\d{4})
Replace by: $2~Sdecember~S$3 -
DBMS_Random.VALUE parameters
Please can anyone describe de DBMS_RANDOM.VALUE(p1, p2) parameters(p1, p2)?
can't random just generate single numbers like:Sure
SQL> r
1 select trunc(DBMS_RANDOM.VALUE(1,10))
2* from (select rownum from dual connect by rownum < 20)
TRUNC(DBMS_RANDOM.VALUE(1,10))
6
3
2
9
1
1
8
2
5
9
7
5
7
8
1
2
1
9
2
19 rows selected.
SQL> -
Change date format in EP when introduce values with "/" as date separator
Hi experts,
We have ECC 6 EHP3 with Enterprise Portal 7 SP 18. We instal BP_ERP5ESS
1.31 SP 4.0, BP_ERP5COM 1.31 SP 4.0, BP_ERP5MSS 1.31 SP 4.0, SAP_ESS
603 SP 4.12 and SAPPCUI_GP 603 SP 4.1
We activate the Travel Management (FIN_TRAVEL_1) business function, so
we use WD ABAP for travel expenses.
The issue is when in the Portal, go to Travel and Expenses and create a
new travel request or a new expense report and introduce the values of
the date with "/" as separator. The system changes the date format, and
change the days for months and months for days, DD/MM/YYYY change to
MM/DD/YYYY. For example if we introduce 31/12/2009, the system change
to 12/31/2009 and gives an error.
If we introduce with "." as separator, 31.12.2009, it works fine, don´t change days for months, so it seems that is not a problem of language settings.
Any idea?
Thanks in advance,
ManuelHi,
You can check the date formate in the portal.........
log in by the Super Super give the user name ...........and check the details..........
in there in the 1st ..view you can set the date formate.............. -
How to change the date format?
Hi,
I need to display the data format as(YYYY-MM-DD). But now it displays(2009-1-9)
Here is my code snippet which i used to display the data format as(2009-1-9)
*<INPUT TYPE=TEXT NAME="date_submitted" MAXLENGTH=20 SIZE=10 VALUE="" onBlur= "return dateSubmitted()"> (YYYY-MM-DD)*
*<SCRIPT LANGUAGE="javascript">*
dateSubmitted()
*</SCRIPT>*
function dateSubmitted()
if (document.pgUpdate.date_submitted.value == "")
date = new Date();
month = date.getMonth() + 1
document.pgUpdate.date_submitted.value =
date.getYear() + "-" + month + "-" + date.getDate();
return true;
Can anybody help me how to change the date format?
Thanks in advance!prit123 wrote:
use SimpleDateFormat class. The code is :He posted a Javascript related question, not a Java related question.
Please use forums devoted to Javascript. You're here at a Java/JSP forum.
There are JS forums at webdeveloper.com and dynamicdrive.com. Good luck.
String formatPattern = "yyyy-mm-dd";
SimpleDateFormat sdf = new SimpleDateFormat(formatPattern);
sdf.format(yourdate);yyyy-mm-dd denotes year-minutes-days. Please go read the SimpleDateFormat API as well. -
Can we change the data type of a field based on the value of the field
HI Gurus,
My Requirement is as below -- Could you please guide me
in the Printable Adobe form -- for ex - as usual for dates fields in the Object Pallette the object type is a date/time field and for quantity/currency fields corresponding fields are taken
now in case the either the date, quantity or currency is initial in place of displaying 0.00 or empty date we need to display N/A (Not Applicable)
for this I would like to change the data type of the field
to put it simply --
we need to change the data type of date field from DATE&TIME to Char type to hold N/A or Quantity field to Char field to hold N/A
how can we realize this in SAP adobe forms
Thanks in Advace
Ramchander Rao.KHello Ramchander,
You cannot change the data type of the field at run time in Adobe forms because the type of field you choose at the time of design level is associated with the data type itself.
If you want to achieve your requirement, then your main idea should be to set the data type as CHARACTER itself while designing the field in the adobe form itself. CHAR field will comfortably hold the value of Calculation/amount field, Currency field, Amount, Date, Time HHMMSS, Unit Accuracy, Currency key, Floating point number, Numeric text, Client, Language and many other data types.
After designing the field as TEXT field in Adobe form you have two options.
Option 1:
Select the Date field initially as type TEXT field or CHAR field in Adobe forms.
Suppose the name of the field is TEXTFIELD1, then write the Javascript code on this field in Initialize event as below.
if ( this.rawvalue == null )
this.rawvalue = "N/A";
If the field is not blank, then it will show the date. Else it will show "N/A".
Option 2:
Select the Date field initially as type TEXT field or CHAR field in Adobe forms. Do the formatting part in ABAP itself. It will increase the performance. Avoid Javascript as much as possible.
Suppose you have a DATE variable l_dats of type DATS. Then take another variable l_date of type CHAR. Then write the below ABAP code.
MOVE l_dats TO l_date.
IF l_date IS INITIAL.
l_date = 'N/A'.
ENDIF.
Bind the l_date to the TEXT field in the form.
Even in this case, if the field is not blank, then it will show the date. Else it will show "N/A".
But I will suggest you to use Option 2 of keeping the AMOUNT, QUANTITY, DATE, TIME fields etc as CHAR or TEXT fields in Adobe form and do the required formatting in ABAP itself. -
How to change the date time format in jsp
Hello Sir,
I am trying to convert the date from one format into another format.
In SQLServer one fields type as datetime.
when i tried to display it in jsp with String variable it shown like below,
2006-08-16 09:11:23.0
how to format this value as
Wed, Aug 16, 2006 09:11 AM
my code is
java.text.SimpleDateFormat fmt= new java.text.SimpleDateFormat("EEE, MMM d, yyyy K:mm a ");
fmt.format(string value fetch from dtabase field);
Plz provide me the solution asap. very urgent request.
Regards
venki.Hello Sir,
I am trying to convert the date from one format into
another format.
In SQLServer one fields type as datetime.
when i tried to display it in jsp with String
variable it shown like below,
2006-08-16 09:11:23.0
how to format this value as
Wed, Aug 16, 2006 09:11 AM
my code is
java.text.SimpleDateFormat fmt= new
java.text.SimpleDateFormat("EEE, MMM d, yyyy K:mm a
fmt.format(string value fetch from dtabase field);
Plz provide me the solution asap. very urgent
request.
Regards
venki.Have a look in to the below code
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateFormatTest
public static void main( String[] cmdArgs )
throws Exception
SimpleDateFormat sdfInput =
new SimpleDateFormat( "yyyy-MM-dd" );
SimpleDateFormat sdfOutput =
new SimpleDateFormat ( "EEE, d MMM yyyy hh:mm aaa" ); //Change the patterns in to what ever u need
String textDate = "2001-01-04";
Date date = sdfInput.parse( textDate );
System.out.println( sdfOutput.format( date ) );
i will suggest u to look in to the API doc you will come to know lot many things. -
Hi all,
How to change a date value from "java.util.Date" to "java.sql.Date"?
I m still confusing what's the difference between them.....
thanks
Regards,
KinThanks
but my sql statement can only accept the format (yyyy-MM-dd)
such as "select * from xx where somedate = '2004-12-31'
but when i show it to screen, i want to show it as dd-MM-yyyy
I m using the following to change the jave.util.Date to str and vice versa. But it cannot shows the dd-MM-yyyy. I tried to change the format from yyyy-MM-dd to dd-MM-yyyy, it shows the wrong date in my application.
public String date2str(java.util.Date thisdate) {
if (thisdate != null) {
java.sql.Date thissDate = new java.sql.Date(thisdate.getTime());
return date2str(thissDate);
} else {
return "";
public String date2str(java.sql.Date thisdate) {
if (thisdate != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(thisdate);
} else {
return "";
public java.util.Date str2date(String thisdate) {
String dateFormat = "yyyy-MM-dd"; // = 1998-12-31
java.util.Date returndate = null;
if (thisdate != null) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
try {
returndate = dateFormatter.parse(thisdate);
} catch (ParseException pe) {
System.out.println (pe.getMessage());
return returndate;
} -
Hi all,
I'm very new to VBA and excel development, so please take that into consideration as you read on.
I'm trying to create a work form for a database that (should) collect various information in comboboxes, including the date, the weekday, and the month... Note: most of the time, the data will be inserted the day after it's been collected. So, I wanted to create
one combobox for the date, one for the weekday, and one for the month, because I want columns for each of these in the database (If this is not necessary/efficient, please help! :) ) .
Here's what I've got so far:
'worksheet setup
Dim ws As Worksheet
Set ws = Worksheets("LookupList")
'Date dropdown setup
Dim cDateToday As Range
For Each cDateToday In ws.Range("DateList")
With Me.cboDate
.AddItem cDateToday.Value
End With
Next cDateToday
'If today is Monday, then set date to last friday, if any other weekday, set it to day before that
If Weekday(Date - 1) <> 2 Then
Me.cboDate.Value = Format(DateAdd("D", -Weekday(Date) - 1, Date), "Medium Date")
Else
Me.cboDate.Value = Format(Date - 1, "Medium Date")
End If
Problem #1: Right now, I am getting the date values from the list
DateList in the worksheet LookupList...is there a better way of doing this?
Problem #2: When the user form is run, the correct date and format shows up. However, if I change the date, the dropdown list in the combobox starts from the initial date in given list...is there anyway to bring the list closer to the current
date? Think Calendar View
Problem #3: I want the weekday and month values to be directly correlated to the date value discussed above, so hypothetically when the user form is run the correct date, weekday, and month all show up (based on the same date value), then if
I change the date, the weekday and month automatically update. Is this possible, if so how?
The reason I want this functionality is so that on a Monday, I can run the work form and it will automatically have Friday's date, weekday, month info as it opens. When I'm done with Friday, I can run it again, switch the date to the Saturday's
date (weekday and month automatically update), then repeat for Sunday.
I have tried running the same code for the weekday and month as I have for the date, and they work
until the date is changed. Once the date is changed, I have to manually change the weekday, which leads to format change, and same for month, which all leads to :( and confusion
Again, I am very new to vba and don't know much about it all and appreciate any/all help!
Thanks in advance!
/AlexI can give you a little advice but I don't understand your comment "if I change the date, the weekday and month automatically update" Where do you want them to update?
I am assuming that your entire question is referring to a Userform with the Combobox. Is this correct?
The code can be much simpler to populate the combobox list. You already have a named range for the Dates so you can use that directly to populate the RowSource. (RowSource if the combox is on a Userform or ListFillRange for a combobox on a worksheet).
Then the WorksheetFunction Workday can be used to get the previous workday without weekend days. It also looks after the previous day when the actual date is mid week. Look up the function on the worksheet Help because you can also have a separate list
of holidays that will be excluded like weekend days.
If you are new to VBA then a tip about Help. You need to be on the worksheet and click Help to get worksheet help and in the VBA editor you click Help to call the VBA help. Don't just select Help off the taskbar when changing between the worksheet and VBA
because you will finish up with the incorrect Help file.
Example of code to assign a named range to the RowSource of a ComboBox. Named range needs to be Global and not scoped to a worksheet otherwise the worksheet name is also required.
Me.cboDate.RowSource = "DateList"
Example of code to assign the previous workday to the combobox value.
'Following line sets value to previous workday (Mon to Friday)
Me.cboDate.Value = WorksheetFunction.WorkDay(Date, -1)
Then there is another problem with ComboBoxes and dates. If the Dates are real dates on the worksheet (Not Text) then the dropdown list displays in the same format as the worksheet but when the date is selected, it displays as a serial number. This
can also be rectified with code but first I need to know what the format of the data is on the worksheet.
Can you upload a copy of your workbook because it is like a picture is worth a thousand words. Same goes for having a copy of the workbook. If it has sensitive data then create a copy and remove the sensitive data.
Regards, OssieMac -
How can I change defaut date format to dd-mon-yyyy in bi analytics
hi..
How can I change the default date format to DD-MON-YYYY in BI Analytics...
I am passing a date in a report from a prompt....but it is always taking "dd-mon-yyyy hh:mm:ss" format...I want to input the prompt in oracle's default date format i.e dd-mon-yyyy..
please help...I dont want to use cast function because it will convert the date into a character value....I want a date...Hi USer
Try this link
How to change date format in OBIEE
Re: repository variable at date prompt
Thanks
Diney -
How to change the date format YYYYMMDD to MM/DD/YYYY
Hi ,
How to change the date format YYYYMMDD to MM/DD/YYYY .
Ex : 20071008 to 10/08/2007
Is there any function module for this ??
Regards
RahulHi Sharma,
check the code:
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-031.
PARAMETERS: date1 RADIOBUTTON GROUP rad1 DEFAULT 'X', "SAP date format YYYYDDMM
date2 RADIOBUTTON GROUP rad1, "Date format like aprial31, 2006
date3 RADIOBUTTON GROUP rad1, "Date format like 31 apr,2006
date4 RADIOBUTTON GROUP rad1, "Date format like DD/MM/YYYY
date5 RADIOBUTTON GROUP rad1. "Date format like DD.MM.YYYY
SELECTION-SCREEN END OF BLOCK b2
FORM getmonth .
SELECT mnr
ktx
ltx
INTO TABLE T_month
FROM t247
WHERE spras = 'EN'.
IF sy-subrc NE '0'.
MESSAGE I "Message - Not able to get month values from the table T247
ENDIF.
ENDFORM.
DATA : temp_date(16) TYPE c,
temp1_date(60) TYPE c,
year(4) TYPE c,
daymonth(11) TYPE c,
daymonth1(11) TYPE c,
month(9) TYPE c,
day(2) TYPE c,
mon LIKE t247-ktx,
len TYPE i .
MOVE date TO temp1_date .
CONDENSE temp1_date NO-GAPS.
MOVE temp1_date TO temp_date .
IF date2 EQ 'X'. "The date format is like Aprial 31, 2007
CONDENSE temp_date NO-GAPS.
SPLIT date AT ',' INTO daymonth year.
IF STRLEN( year ) NE '4'.
error = 'X'.
WRITE : 'Invalid date format.'.
ELSE.
daymonth1 = daymonth.
CONDENSE daymonth1 NO-GAPS.
_len = STRLEN( _daymonth1 ).
l_len = 13 - len.
SHIFT daymonth1 RIGHT BY len PLACES.
CONDENSE daymonth1 NO-GAPS.
month = daymonth1.
CONDENSE month NO-GAPS.
SORT t_month BY monthltx.
READ TABLE t_month WITH KEY monthltx = month.
IF sy-subrc <> 0.
error = 'X'.
WRITE : 'Invalid date format.' .
ELSE.
len = STRLEN( month ).
CONDENSE daymonth NO-GAPS.
SHIFT daymonth LEFT BY len PLACES.
day = daymonth.
CONDENSE day NO-GAPS.
CONCATENATE year t_month-monthnumber day INTO o_date.
ENDIF.
ENDIF.
ELSEIF p_date3 EQ 'X'. "The date format is like 31 apr, 2007
CONDENSE temp_date NO-GAPS.
SPLIT i_date AT ',' INTO daymonth year.
IF STRLEN( year ) NE '4'.
error = 'X'.
WRITE : 'Invalid date format.'.
ELSE.
daymonth1 = daymonth.
CONDENSE daymonth1 NO-GAPS.
SHIFT daymonth1 LEFT BY 2 PLACES.
CONDENSE daymonth1 NO-GAPS.
month = daymonth1.
CONDENSE month NO-GAPS.
TRANSLATE month TO UPPER CASE.
SORT t_month BY monthstx.
MOVE month to mon.
READ TABLE t_month WITH KEY monthstx = mon.
IF sy-subrc <> 0.
error = 'X'.
WRITE : 'Invalid date format.' .
ELSE.
CONDENSE daymonth NO-GAPS.
day = daymonth+0(2).
CONDENSE day NO-GAPS.
CONCATENATE year t_month-monthnumber day INTO o_date.
ENDIF.
ENDIF.
ELSEIF p_date4 EQ 'X' OR p_date5 EQ 'X'. "Date format is like DD.MM.YYYY or DD/MM/YYYY
CONDENSE temp_date NO-GAPS.
IF STRLEN( temp_date ) EQ 10.
o_date0(4) = temp_date6(4).
o_date4(2) = temp_date3(2).
o_date6(2) = temp_date0(2).
ELSE.
error = 'X'.
WRITE : 'Invalid date format.' .
ENDIF.
ENDIF.
IF STRLEN( o_date ) NE '8'.
error = 'X'.
WRITE : 'Invalid date format.'.
ENDIf.
ENDFORM. " f0100_conv_date
Reward if helpful.
Regards,
Harini.S -
How to change the date format in Sharepoint 2010 to dd MMM yyyy
Hi,
I am looking to change the datetime format with in the modified column from mm/dd/yy to dd MMM yyyy. I dont want to create calculated field with dd MMM yyyy format. I want the actual modified column value to be represented as dd MMM yyyy format.
Thanks for your help in advance.
regards
KalyanI'm not really sure what context you asking to change this for but to change your date time settings -
Go into Site Settings and under 'Central Administration' there is a link to 'Regional Settings'. Click this and you specify the way dates and times are displayed.
I have done this and mine displays as DD/MM/YYYY like you are asking.
My locale is current set to English (United Kingdom) and sort order is general. Even if you're not in the United Kingdom, I can only see this way being your solution as US dates are always set as MM/DD/YYYY.
http://sharepointythings.blogspot.co.uk
Maybe you are looking for
-
I recently upgraded my Iphone 4s to 5.1.1 and founf the Wi-Fi button in settings greyed out saying No Wi-Fi. I have tried Reset network Settings, Rest All Settings and restore in Itunes but to no avail. I understand this is a comon occurence but I
-
about a month ago, Mavericks had an automatic update. I have a Windows 7 partition bootcamped on my macbook pro. Before the update, everything was fine. Now, when I attempt to start Windows partition, as soon as I touch the keyboard or mouse the scre
-
hi , I have a JTable contructed from DeaultTableModel and i have created a TableCellEditor which has a custom DefaultCellRenderer as its argument and added to the table THE PROBLEM is : When i edit in the table cell , the editable area of the cell be
-
Username and password through SOAP header
Hi Gurus I am developing web service model in webdynpro by consuming third-party WSDL. This third party web service expecting me to send the user name &password through SOAP header. Can any body tell me how to pass the username password through SOAP
-
Problem in ME55 in SAP ECC 6.0
Dear All, I am facing a problem in ME55. If I specify the Purchase requisition no in ME55, then Release can be possible for 1st Release Code. But when I remove Purchase Requisition no from ME55, then system shows "No Record found" for same release co