Convert Date to String but maintain a MM/DD/YY format
I have converted a date field to a string without a problem. However, when I use it in a report, the entire date/time from the original date field prints. How do I get only the MM/DD/YY format to print once I've converted it to a string or how do I convert the field to a MM/DD/YY format before converting it to a string?
THis should give you what you are looking for...
ToText({TableName.DateField}, "MM/dd/yy")
note: the MM instead of mm... "M" is for months, "m" is for minutes...
HTH,
Jason
Similar Messages
-
Function module to convert date form yyyy/mm/dd to dd/mm/yyyy format
Can any one tell me Function module to convert date form yyyy/mm/dd to dd/mm/yyyy format?
have a look at the WIKI FAQs...they are very useful
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abapDevelopmentand+Programming&
For this it says:
<i>How to convert a date to internal or external format?
Use the functions modules CONVERT_DATE_TO_EXTERNAL or CONVERT_DATE_TO_INTERNAL
to convert the date. When converting to external format, the date format from the user's user profile will be used. When converting to internal format, the result will be in YYYYMMDD format.</i> -
Converting date from DD.MM.YYYY to YYYY - MM - DD format
Hi All,
Can you give me a way to convert date from DD.MM.YYYY to YYYY - MM - DD format. Actually frm tables i am getting date in DD.MM.YYYY format. And i want to print it in YYYY-MM-DD format.
Please reply.
Thanks And Regards,
Mayank Verma
Moderator message - Please search before asking. Date formatting is one of the most common questions asked - post locked
Edited by: Rob Burbank on Jul 6, 2009 10:42 AMHi,
Hey you can make use of offset and concatenate statement to convert the date.
regards,
Ankur Parab -
Hi All,
I have a dimension member in my classic plannnig application whose datatype is Date,
Now i want to use that member inside the following function:
@TODATE(<date format goes here> , <date string goes here>);
e.g
@TODATE("mm-dd-yyyy" , "Dimension Member Name");
Now the second parameter to this function is of string type, whereas the data type of my member is "Date", so is there any way to convert this date to string?
Notes:-
I am using the above script inside the member formula.
I run the code with some static value e.g.
@TODATE("mm-dd-yyyy" , "01-12-2011"); and it works quite fine so i am pretty much sure that issue is related to incompatible data types.Have a look at the following post it should give you an idea - Re: @DatePart formula produces constant result
Cheers
John
http://john-goodwin.blogspot.com/ -
I am querying the database to return a date column. I want to map it to a String but format it as "Jan-31-3010'. am running into issue with this
NAy suggestiions.Dan.
I am getting the date returned from database. that is what is messing up
so here is what i do
for each row in executeQuery(DynamicSQL, sentence : sqlString, implname :"DATABASE_URL", inParameters : null) do
if row["start_date"] != null then
startDate as Time = Time(row["start_date"])
sDate as String = formatDate(DateUtil, argDate : startDate)
end
end
I send the startDate which is of Type Time to a user defined method formatDate
code for format date is
returnFmtDate as String
if (argDate != null) then
sfm as SimpleDateFormat = SimpleDateFormat("yyyy-mm-dd")
returnFmtDate = format(argDate, formatter : sfm)
end
some reason the argDate parameter has the value 2010-05-20 00:00:00-07:00 but the returnFmtDate is being set to "2010-00-20" -
Convert date in modal binding table into dd.mm.yyyy format
DEar ALL,
i have a date in the modal table, this value is coming from r/3 in yyyymmdd format. But i need to change its format to dd.mm.yyyy. How can i achieve it..i don't want to create my own table...pls suggest
Regds,
Anup.Hi Anup,
Is the field that is coming from R/3 of type DATE?
If yes then the conversion of the date should be automatic, and the display will be according to your locale, user language, browser language.
You can set the format using
String date = (new SimpleDateFormat("MM/dd/yyyy").format(new java.util.Date()));
Hope this helps.
Regards,
Shubham -
Function module to convert date form yyyy/mm/dd to mm/dd/yyyy format
can any one tell meFunction module to convert date form yyyy/mm/dd to mm/dd/yyyy format
hi
good
try this
report zrich_0001.
tables s002.
data ilikp type table of likp.
ranges: r_datum for sy-datum.
select-options: s_spbup for s002-spbup.
start-of-selection.
r_datum-sign = 'I'.
r_datum-option = 'BT'.
r_datum-low = s_spbup-low.
r_datum-low+6(2) = '01'.
if s_spbup-high is not initial.
r_datum-high = s_spbup-high.
r_datum-high+6(2) = '01'.
else.
r_datum-high = r_datum-low.
endif.
r_datum-high4(2) = r_datum-high4(2) + 1.
r_datum-high = r_datum-high - 1.
append r_datum.
select * into table ilikp from likp
where erdat in r_datum.
thanks
mrutyun^ -
Converting date time string to double data
I have to plot a bar chart. The VI accepts only 2-d double data. My X- axis is date timestamp and Y- axis is the double data.
Bt I am unable to convert the timestamp value to double.
Anyone can suggest anything ?
Regards,
Runjhun.Thnx a lot Darin.
Bt may be I should be more clear with my reqmts.
In the image attached the data to be plotted is stored in Excel from LabVIEW.
And the graph is plotted in Excel selecting the data.
Plotting of graph is maual.
I want that the graph plotting should be automatic.
In RGT der's a function Excel Plot Graph bt the problem is dat it takes only 2d double array as I mentioned earlier.
May be dis wil make my problem clearer.
Regards,
Runjhun A.
Attachments:
plot_type.jpg 3724 KB -
Hi, I have the following query:
select * from table1 a where completed between to_date('10 May 2013 11:31', 'DD Mon YYYY hh:mi') and to_date('10 May 2012 11:31', 'DD Mon YYYY hh:mi');
I see records in the database between those dates in that column but the query is not returning anything.. any ideas why my formating is not picking them up?
Thanks,malky wrote:
Hi, I have the following query:
select * from table1 a where completed between to_date('10 May 2013 11:31', 'DD Mon YYYY hh:mi') and to_date('10 May 2012 11:31', 'DD Mon YYYY hh:mi');
I see records in the database between those dates in that column but the query is not returning anything.. any ideas why my formating is not picking them up?
Thanks,you need to REVERSE the order on the BETWEEN
between to_date('10 May 2012 11:31', 'DD Mon YYYY hh:mi')
AND to_date('10 May 2013 11:31', 'DD Mon YYYY hh:mi') ; -
How to convert date which is coming from a file
Hi All,
I am reading the content from the file in which date is also one field, but i am while inserting into the database i'm getting an exception because it is not able
to insert into the database because the database date format is different from the one which is coming from a file.
The datatype value of the database is Date.
Can anyone help me on this if anybody having an idea.
Regards,
CHHi,
Even if I'm using JavaEmbeddedActivity also i'm getting an error. Please have alook at the below code once
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class ConvertDateToStringExample {
public static void main(String args[]){
DateFormat dateFormat = new SimpleDateFormat("dd-nn-yyyy hh:mm:ss");
//to convert Date to String, use format method of SimpleDateFormat class.
String strDate = dateFormat.format(getVariableData('inputVariable','payload','/client:process/client:Date'));
System.out.println("Date converted to String: " + strDate);
Error Message:
Error(21,33): Failed to compile bpel generated classes.
failure to compile the generated BPEL classes for BPEL process "DateProcess" of composite "default/DateProcess!1.0"
The class path setting is incorrect.
Ensure that the class path is set correctly. If this happens on the server side, verify that the custom classes or jars which this BPEL process is depending on are deployed correctly. Also verify that the run time is using the same release/version.
Well it's not at all allowing me to insert the format while passing the input arguments.
Regards,
CH -
Hello,
My requirement is that I need to concat a string with a date. I tried to convert the date to char but I am not getting the date format and then want to contact with the string.
here is the requirement:
Contact Date: 12/08/2011.
In order to do this, I tried to convert the date into string but having difficulty in getting the date format.
any help is appreciated.
Thanks -manyam16 wrote:
Hello,
My requirement is that I need to concat a string with a date. I tried to convert the date to char but I am not getting the date format and then want to contact with the string.
here is the requirement:
Contact Date: 12/08/2011.
In order to do this, I tried to convert the date into string but having difficulty in getting the date format.
any help is appreciated.
Thanks -The "tricky" part to what you are asking for is that when you cast a date column as char, the format may change. For example, when I look at my system date as is (it is a date field), the format is as follows:
1/26/2012 5:53:11 AM
When I cast it as CHAR, it appears as follows:
2012/01/26 05:53:11
Why am I saying this? Because the details of the next step will be determined by where the characters are in the string. For this exercise, I will assume that after casting to CHAR, the format is as you say. Then the stringing should look something like this:
Contact Date: 12/08/2011. SUBSTRING(CAST("your date column" AS CHAR) FROM 1 FOR 2) ...to give you the 12
SUBSTRING(CAST("your date column" AS CHAR) FROM 4 FOR 2) ...to give you the 08
SUBSTRING(CAST("your date column" AS CHAR) FROM 7 FOR 4) ...to give you the 2011
So concatenating them, you get:
SUBSTRING(CAST("your date column" AS CHAR) FROM 1FOR 2)||'/'||SUBSTRING(CAST("your date column" AS CHAR) FROM 4 FOR 2)||'/'||SUBSTRING(CAST("your date column" AS CHAR) FROM 7 FOR 4)
Now you can concatenate your text to the above string... -
Change Variable Type P to STRING but with thousand separators
Dear all,
I am no specialist (in abap/bsp).
I have a variable 'number' type p decimals 0.
I need that 'number' converted to a string but with the thousand separators.
Is there a function available?
Is is possible to give this function the desired character as a thousand separator?
E.g.
Character '.' for German Number Format
Character ',' for US Number Format.
Thank you in advance for help.
Rewarding Points for helpful answers guaranteed.
PhilippHi Philipp,
I have written a report for you.
Just copy & paste the below code in your report.
Try changing the num variable in the report and see the result.
DATA: num TYPE p DECIMALS 0,
de_str TYPE string,
en_str TYPE string.
DATA: temp_str TYPE string,
str_len TYPE i,
count TYPE i,
index TYPE i,
sub_str TYPE string,
sub_str_len TYPE string.
num = 1234567890.
temp_str = num.
str_len = STRLEN( temp_str ).
str_len = str_len - 1.
IF str_len >= 3.
count = str_len DIV 3.
index = 0.
DO count TIMES.
sub_str_len = ( count ) * 3.
count = count - 1.
index = str_len - sub_str_len.
IF index < 3.
sub_str_len = index.
index = 0.
ELSE.
sub_str_len = 3.
index = index - sub_str_len.
ENDIF.
IF index NE 0 OR sub_str_len NE 0.
sub_str = temp_str+index(sub_str_len).
CONCATENATE de_str sub_str '.' INTO de_str.
CONCATENATE en_str sub_str ',' INTO en_str.
ENDIF.
ENDDO.
index = str_len - 3.
sub_str = temp_str+index(3).
CONCATENATE de_str sub_str ',' '000' INTO de_str.
CONCATENATE en_str sub_str '.' '000' INTO en_str.
ELSE.
sub_str = temp_str+0(str_len).
CONCATENATE de_str sub_str ',' '000' INTO de_str.
CONCATENATE en_str sub_str '.' '000' INTO en_str.
ENDIF.
WRITE: temp_str,
/ de_str,
/ en_str.
Hope it helps you.
Regards,
Maheswaran B
I have done a small change. Try it now!
Maheswaran B
Message was edited by:
Maheswaran B -
Conversion of Date to String in JSP..
Please help....
wat should i do to convert Date to String in my JSP Page?
Thank you....SimpleDateFormat class
-
Dear All
I am trying to convert LRAW to STRING, but all the FMs available are for RAW to STRING.
Is there any FM that can convert LRAW to RAW keeping in mind that the LRAW field has length about 32000
<moderator: please use meaningfull subject!>
Edited by: Jan Stallkamp on Aug 6, 2008 2:39 PMHi Vaibhav
I had solved this problem with a different work around where I used the ABAP program for sxmb_moni and used its features to get the output.
Thanks -
Convert date 17-sep-2007 to 2007-09-17 format
Is it possible to convert date say 17-sep-2007 to YYYY-MM-DD format?
if so is there any Function module to implement this?
Awaiting for ur reply....................Hello,
try this
REPORT ZTEST.
DATA : V_DATE LIKE SY-DATUM,
V_DATE1(10).
V_DATE = '01012007'.
CONCATENATE V_DATE4(4) V_DATE2(2) V_DATE+0(2) INTO V_DATE1.
WRITE : V_DATE1.
Reward if helpful,
Regards,
LIJO
Maybe you are looking for
-
Method to be used to delete a particular select parameter in a Sales order
Hi , Which Method can be used to delete a particular select parameter in a Sales order search screen using class CL_CRM_BOL_DQUERY_SERVICE
-
Looking for Online Coldfusion Tutor
Hello, I'm looking for a tutor to work with me and teach me advanced topics/techniques in coldfusion. I think this can be done easily using the phone and join.me. Does anyone know of any coldfusion tutors or websites that I can find someone? Please
-
Backing everything up over IP and not WiFi?
Is there someway to use a external hard drive or Apple Time Capsule with Time Machine when I am not at home using my WiFi network? Maybe I am on vacation and I want to backup everything over IP to my home Time Capsule or external drive. Thanks.
-
HP7350 Can't print in black & white
Hi, I have the 21" iMac with a HP7350 printer (usb). For some reason I can't find any way to print a web page or the like in plain old black and white. I tried to download the newest driver for the printer, but being a Mac noob, I probably didn't ins
-
Is there any listener when leaving the page?
Hi, I use JDev 11g, I use this *((DCIteratorBinding)this.getBindings.get("MyIterator1")).getViewObject().getApplicationModule().getTransaction.isDirty();* to know if there is a change happen in database or not I want to check this change when I leave