Bad date format string in Crystal 2013
I have a report that I wrote a formula to convert the date from a number to a date recognizable by the end user. It works fine. The user then wanted to add another field to the same report. Same type of deal, so I copied the first formula into a new formula for the second conversion and simply changed the file name that it was pulling from. When I check the formula, it comes back no errors found, but when I insert it into the report, I get an error that says "Bad date format string" it's the exact same formula that runs fine in the field next to it. What am I missing? The exact formula as used is;
date(mid(totext({File.name},0,' '),5,2)+'/'+ right(totext({File.Name},0,' ' ),2) + '/' + left(totext({File.Name},0,' '),4)) It is intended to take it from 20140405 to 04/05/2014.
Any help would be greatly appreciated. As I am new to Crystal reports and by no means a database administrator by trade.
Thanks
Bob V.
hi Bob,
you can use something like the following
stringvar s:= '20140405';
date(s[1 to 4] + '/' + s[5 to 6] + '/' + s[7 to 8])
and if you want to be safe and use a check, then you can use something this
stringvar s:= '20140405';
s:= s[1 to 4] + '/' + s[5 to 6] + '/' + s[7 to 8];
if isdate(s) then date(s);
-jamie
Similar Messages
-
BAD DATA FORMAT using cl_gui_frontend_services= gui_upload
Hello SAPients!
I'm using the method cl_gui_frontend_services=>gui_upload to upload a file to my program like this
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lvs_input_f1
filetype = 'ASC'
CHANGING
data_tab = in_rec[]
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
The SY-.SUBRC field always returns with a value of 8 (Bad data format?). The thing is that the last field of the structure IN_REC is of type i (integer) and I think this is the problem. I modified the file with a text editor and set the last field with 2, 4, 8 and 16 chars but I always receive the same error. I can't change the last field to char. Does any one have an idea of what is the problem? How can I ensure that the last field have an integer value?
Thank you.Ok, I have modified the code a bit, you might want to try it. First upload to a table of type STRING, then move the values to the other internal table.
report zrich_0001 .
data: begin of in_rec occurs 0,
matnr(18), "Material Number
bwkey like mbew-bwkey, " For Plant
werks like mbew-bwkey, " Add Plant
type(2) type c, " TYPE.
cname(50) type c, " Changble Name
bom(1) type c, " BOM Usage
task(2) type c, " task type
verid_nd like ckmlmv001-verid_nd, "Production Version
perc(16) type c, " Percent for Plant1
* above are user inputs ; below are program flag.
flag(1) type c, " Program flag.
kalnr like ckmlmv001-kalnr, "
mix_flag(1) type c, " Program flag.
cnt type i,
end of in_rec.
data: istr type table of string with header line.
parameters: p_file type localfile.
at selection-screen on value-request for p_file.
data retfiletable type filetable.
data retrc type sysubrc.
data retuseraction type i.
call method cl_gui_frontend_services=>file_open_dialog
exporting
multiselection = abap_false
changing
file_table = retfiletable
rc = retrc
user_action = retuseraction.
read table retfiletable into p_file index 1.
start-of-selection.
perform open_file.
*& Form OPEN_FILE
form open_file.
*------------------------ Begin Change - UN001 ------------------------*
* CALL FUNCTION 'WS_UPLOAD'
* EXPORTING
* filename = input_f1
* filetype = 'DAT'
* TABLES
* data_tab = in_rec.
data:
lvs_input_f1 type string. " To store filename
* lit_mat_tbl TYPE TABLE OF lt_raw_tab, " To store file lines
* lwa_mat_tbl TYPE lt_raw_tab. " Work area
lvs_input_f1 = p_file.
* lvs_input_f1 = input_f1.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = lvs_input_f1
filetype = 'ASC'
changing
data_tab = istr[]
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 19.
if sy-subrc ne 0.
* WRITE / text-e01.
message e000(fb) with text-e01.
endif.
loop at istr.
in_rec = istr.
append in_rec.
endloop.
loop at in_rec.
write:/ in_rec.
endloop.
*------------------------ End Change - UN001 ------------------------*
*SKD 08/02/06---------DEVK980441-----------v
delete in_rec where perc = 0.
*SKD 08/02/06---------DEVK980441-----------^
endform. "OPEN_FILE
Regards,
Rich Heilman -
How to get the system date format string?
Hello, everybody!
I want to create a MaskFormatter with a mask for dates. So, I could suply as the constructor parameter: "##/##/####'. However, what if the year comes first in the current system date format settings, or the month is in the second place or in the first?... So, I can't just suppose that the current locale format for dates is like the one above. So, my question is: is there a way to get the SYSTEM DATE FORMAT STRING in Java? Searching in google I saw that this was already asked in this forum:
http://forum.java.sun.com/thread.jspa?threadID=301034&messageID=1193794
but there was no effective answer. Does someone already know how to get this?
Thank you.
MarcosHi, not sure, but
import java.text.*;
SimpleDateFormat sdf = new SimpleDateFormat();
System.out.println(sdf.toPattern());
will output something like dd/MM/yy HH:mm
hthThank you very much. It worked. -
I18n for custom date format strings
I want to internationalize dates shorter than DateFormat.SHORT, in the form "M/d". For example, when the Locale is US, January 16 should display as 1/16, but if the Locale is MX (Mexico), it should display as 16/1.
It seems like a very simple problem date formatting problem, but it doesn't look like the DateFormat/SimpleDateFormat classes have any way of doing this. Am I missing something?
--StevenYou need to apply your own customized date pattern to get the formats you want. I suggest you put the patterns in resource bundles...the default pattern in your default bundle, and the Mexican pattern in your bundle for Mexico. Then do something like this:
<pre>
<code>
String newPattern = "M/d"; // retrieve from bundle instead
Date today = new Date();
DateFormat df = DateFormat.getInstance();
SimpleDateFormat simpleFormat = (SimpleDateFormat)df;
simpleFormat.applyPattern(newPattern);
System.out.println(df.format(today);
</code>
</pre> -
Is is possible to allow multiple date format strings pass DateFormat.parse?
I'm trying to use DateFormat.parse to validate a date in the 20/12/08 format. I would like to allow users to input 20-12-08 or 20 12 08.
The code currently looks like this:
formatter = DateFormat.getDateInstance(DateFormat.SMALL, US);It is currently throwing an exception if 10-12-08 is sent in where as 10/12/08 works just fine.
Is there a alternate us locale that is more lenient?
setLenient(true) didn't solve the problem for me. I think that would accept 32/12/08 not 10-12-08.
I could parse the date string and replace - or ' ' with a /.. Is that best practice?
What other options do I have? Could I use SimpleDateFormat somehow?
Thanks for the inputThat just doesn't seem clean. It will work, but I would rather not have a valid application flow use an exception to get its job done.
The application is also international, so many locales on one format is valid. The US user base seems to think they can type in the date however they want. So passed into the method is the locale, I would have to modify a lot of code to send in a list of valid locales.
The best solution for me would be to have a locale that would allow - or ' ' or /. That way I still only have to make one call to df.parse and an exception produces an invalid date message. Is that possible?
Thanks -
"Bad data format" when reading txt file from the presentation server
Hello,
I have a piece of code which reads a txt file from the presentation server to an internal table like below:
DATA : lv_filename type string.
lv_filename = 'C:\abap\Test.txt'. "I created a folder called abap under C:\
CALL method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = lv_filename
CHANGING
DATA_TAB = lt_tsd. " lt_tab has the exact same fields as the Test.txt's. Test.txt has only one line, tab delimited.
When running this code, exception BAD_DATA_FORMAT is issued.
Is it because of the file encoding or delimiter or other reason?
Thanks,
YangHello,
If its tab delimited then use the has_field_seperator parameter and check
DATA : lv_filename type string.
lv_filename = 'C:\abap\Test.txt'. "I created a folder called abap under C:\
CALL method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = lv_filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = u2018Xu2019
CHANGING
DATA_TAB = lt_tsd.
Vikranth -
Bad date format in generated client API (weblogic server Workshop)
Hello,
i'm making web service client from oracle weblogic workshop.
I have used "clientgen" Ant task to generate the client library.
The WSDL indicates that certain fields are of type xsd:date.
<xs:complexType name="declarationType">
<xs:sequence>
<xs:element ref="directive"/>
<xs:element ref="deadline"/>
<xs:element ref="complete"/>
<xs:element ref="transposition"/>
<xs:element ref="comment"/>
</xs:sequence>
</xs:complexType>
<xs:element name="deadline" type="xs:date">
<xs:annotation>
<xs:documentation>Deadline (date) for executing this directive.</xs:documentation>
</xs:annotation>
</xs:element>
So in the API generated, i've a function generated to set the deadline with java.util.Calendar as parameter.
If i construct my message and pass 2010-07-06 to the function that initialise the deadline date(in yyyy-mm-dd)
The web service client sends "2010-07-06+02:00". (because i'm locate in Bruxelles in Belgium)
However, the server expects "2010-07-06". (yyyy-mm-dd)
So how can I do to pass it correctly?
i've tried in a message handler, but i've to sign the body of the message.
So when i modify the body in the handler to format the date, i receive an error from the server because the signature isn't valid.
How can i change the format of the date passe, before signing of the body.
thanks in advance.By "client's principle", do you mean the identity of the user who got logged
in? You should be able to call HttpServletRequest.getUserPrincipal() or in
EJB land SessionContext.getCallerPrincipal(). Also, if this is the identity
you are interested in you just be able to call the EJB and then use
getCallerPrincipal() as the identity should be propogated across the wire.
- Neil
"Raymond Tiong" <[email protected]> wrote in message
news:[email protected]..
>
I'm posting this at the risk of sounding as if I didn't read thedocumentation
before hand. (Which I've only glanced through to be honest.)
I want to be able to retrieve the SSL information, particularly theclient's principle
in order to pass it to an EJB to retrieve user specific information.
Is this possible? If how, what are the steps in general?
In Workshop, in the JWS file, which api's do I call?
Thanks in advance,
Ray -
Change date format in ms excel 2013 form MM-DD-YYYY to DD-MM-YYYY
Dear sir
I have got a database from my client where the entire dates are in MM-DD-YYYY format. However my system runs in DD-MM-YYYY format(based on my company lines).
So i need to convert this MM-DD-YYYY to DD-MM-YYYY format
Please help
Thank youIf you want to change the format in excel ,Click 'Home' Tab in the Ribbon-> In 'number 'Group->Choose 'more number format'-> 'custom'->change the 'type' as "DD-MM-YYYY".
Or use the formula =TEXT(A1,"DD-MM-YYYY")
If you want to change the format when export it from SQL Server Database to excel.
Use
select Convert(VARCHAR(10),column name,105) as date from
database name -
Converting String Date to Date Format
Hope you can help, I am tearing my hair out. I have a 2D table that stores information. I have a field that records a date in the format 03-May-11 (this is a string). However, it is also stored as a number 40666 in a sortkey field. The string field is CLIENT2D.INFO1 and i have tried to use Date({CLIENT2D.INFO1}) to show as a date, which it does, until i want to use it as a parameter i.e. bring records between two dates. It errors and comes up with bad date format.
Is the 40666 number Unix Time? If so is there anyway to convert this to a Date 03/05/11?Try
CDate({CLIENT2D.INFO1})
Ian -
Translating a date format in a filename string
Hi,
Basically I have a property like:
filename=MyFile(yyyy-MM-dd@HHmmss).logWhen I create the file I want to translate the embedded date format string using the current date.
My solution is as follows:
private static void createFile(String fName) {
String[] fNameArray = new String[3];
int openBracket = fName.indexOf("(");
int closeBracket = fName.indexOf(")");
// Split the file name into prefix, text inside brackets ie to be tranlated to a date and suffix
fNameArray[0] = fName.substring(0, openBracket+1);
fNameArray[1] = fName.substring(openBracket+1, closeBracket);
fNameArray[2] = fName.substring(closeBracket);
String dateFormat = fNameArray[1];
DateFormat df = new SimpleDateFormat(dateFormat);
String date = df.format(new Date());
fNameArray[1] = date;
fName = fNameArray[0].concat(fNameArray[1].concat(fNameArray[2]));
...This seems a little long winded to me (it works though). Does anyone know of a simpler way to code this?
Many ThanksI've been looking around and came across String.format() which can be used to format strings using substitutions variables.
This works a treat but I must admit the property now looks a bit complex!
String fName = "MyFile_%1$tY%1$tm%1$td%1$tH%1$tM%1$tS.log";
fName = String.format(fName, Calendar.getInstance());
// fName = MyFile_20060803132200.logThanks for your help. -
Date format conversion in BEX query level
Hi ,
We had a date field in the numeric format like 735.020 in the cube level, but when we execute the query the values for thsi date field is changed in to date format like 31.05.2013.
we are not having any conversion routines and the date fields are used directly in the query .Hi,
Try the below class file or may be create a method in your controller. It will resolve your problem.
package com.XXX.DateFormatForSAP;
import java.util.Date;
import java.text.SimpleDateFormat;
public class FormatSAPDate {
public static String changeDateFormat(Date sapDate) {
String formattedDate = null;
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
formattedDate = dateFormat.format(sapDate);
return formattedDate;
Try this code and let me know.
Regards
Mukesh -
I have Problem in Upload Date formate
Hi Friends,
I have one doubt on WDJ.
I have done one Application that application having one functionality that is Download data in to Excel. After download data into excel we can change the DATE cell and again upload Excel Data.
Here what I am getting problem is download data into SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); this date forame. And again upload data into Same date formate
But it is not uploaded
When I download data into SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); this date format that time it will upload successfully.
This is for Dowload data into Excel
if(StockEle.getConf_Shp_Date()==null)
ExcelEle.setConf_Shp_Date("null");
else
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
Date ConfShpDate = wdContext.nodePoDetails_OutTab().getPoDetails_OutTabElementAt(i).getConf_Shp_Date();
String ConfShpDate1 = sdf.format(ConfShpDate); // will give dd-MM-yyyy
ExcelEle.setConf_Shp_Date(ConfShpDate1);
Here ExcelEle.setConf_Shp_Date data type is String
This is for Upload data
try
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
//Date dt = sdf.parse(ele.getConf_Shp_Date());
// java.util.Date Date dt = sdf.parse(ele.getConf_Shp_Date());
java.util.Date dt = sdf.parse(ele.getConf_Shp_Date());
java.sql.Date sqlDate = new java.sql.Date(dt.getTime());
eleout.setEindt(sqlDate);
catch(Exception e)
e.printStackTrace();
eleout.setEindt data type is Date.
How to Solve this issue I want upload this type of date (dd.MM.yyyy).
Regards
Vijay KalluriHi
Try to format it before sending it back , try using these code
// Create Date object. Date date = new Date();
//Specify the desired date format
String DATE_FORMAT = "MM/dd/yyyy";
//Create object of SimpleDateFormat and pass the desired date format.
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
/* Use format method of SimpleDateFormat class to format the date. */
System.out.println("Today is " + sdf.format(date) );
Best Regards
Satish Kumar -
Non US date format within Workspace and Guides
Is is possible to change the date format displayed within the workspace and Guides to a non US date format?
This really is a show stopper for us as our standard date format is DD/MM/YYYY and the forms won't be usable for our staff if they are not in this format.For Workspace, the date format strings are provided in the localized resource swfs so if you need to change them, can either update the resource swf in question, or possibly provide a new one for the locale you really want to service. The shipping english swf is named workspace_rb_en_US.swf so maybe you want to provide another one with a different en_XX suffix. The Workspace source is shipped with the product and I think the Customizing Workspace doc explains how to do this. The ES2 version of the doc may not be ready yet, but the ES version should explain the concepts. You may need a hotfix to get the proper ant scripts to build it, but you would have to check with support on this.
-
Create unique Form ID - Help on Date Format in Concat
I am having problems formating a date value in my concat statement. I have tried to write is different ways and still can't seem to get the string correct.
Ideally, I would like to change the date value to a Julian value for the form ID, but I would settle for just mmddyy value without the / or - in between.
Codes I have tried w/out date format string
JavaScript - Calculate
Program.FormID.rawValue=Program.State.rawValue + Program.ProgramNumber.rawValue + Program.ProgramDate.formattedValue;
Returns - MO1234Jul8,2010
-------------And--------------------
Program.FormID.rawValue=Program.State.rawValue + Program.ProgramNumber.rawValue + Program.ProgramDate.rawValue;
Returns - MO12342010-07-08
FormCalc - Calculate
(This one has the current date as a value, but it changes the unique form ID when reopened on another day, that is why I am using ProgramDate)
Concat(Date2Num(Date(), "ddmmyyy"),Program.State.rawValue, Program.ProgramNumber.rawValue)
Returns - 0MO1234
----------- And --------------------
if
(Program.ProgramNumber.rawValue ne null) then
$.rawValue
= CONCAT(Program.State.rawValue, Program.ProgramNumber.rawValue, Program.ProgramDate.formattedValue)
else
$.rawValue = ""
endif
Returns - MO1234July8,2010 (formattedValue)
MO12342010-07-08 (rawValue)
What would be the better language to use, FormCalc or JavaScript for this example?
I am not all that skilled at coding and use forums like this to help me, so I appreciate any help.
Thanks in advance - EveDate.prototype.yyyymmdd = function() {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
return yyyy + (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]); // padding
Now, after having spliced the internal Date object, you can do this:
d = new Date();
d.yyyymmdd();
The line above returns today's date: "20100709". -
Hy,
I've got a problem when we insert a timestamp to a db.
When I try to start an insert code I get this error:
SQL-Error: ORA-01830: "data format picture ends before converting entire input string"
Insert into ABC_123("dtstamp") values (to_timestamp('31.05.13 09:30:05,000748000 +01:00','DD.MM.RR HH24:MI:SSXFF'));
with this language settings
National Language Support
National
Language Parameter
Value
NLS_CALENDAR
GREGORIAN
NLS_CHARACTERSET
WE8MSWIN1252
NLS_COMP
BINARY
NLS_CURRENCY
€
NLS_DATE_FORMAT
DD.MM.RR
NLS_DATE_LANGUAGE
GERMAN
NLS_DUAL_CURRENCY
€
NLS_ISO_CURRENCY
GERMANY
NLS_LANGUAGE
GERMAN
NLS_LENGTH_SEMANTICS
BYTE
NLS_NCHAR_CHARACTERSET
AL16UTF16
NLS_NCHAR_CONV_EXCP
FALSE
NLS_NUMERIC_CHARACTERS
NLS_SORT
GERMAN
NLS_TERRITORY
GERMANY
NLS_TIME_FORMAT
HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT
DD.MM.RR HH24:MI:SSXFF
NLS_TIMESTAMP_TZ_FORMAT
DD.MM.RR HH24:MI:SSXFF TZR
NLS_TIME_TZ_FORMAT
HH24:MI:SSXFF TZR
I didn't see the error. Maybe somebody can help me.
Thx
Felixef5fe917-5142-4425-a464-94ab111ed87a wrote:
Hy,
I've got a problem when we insert a timestamp to a db.
When I try to start an insert code I get this error:
SQL-Error: ORA-01830: "data format picture ends before converting entire input string"
Insert into ABC_123("dtstamp") values (to_timestamp('31.05.13 09:30:05,000748000 +01:00','DD.MM.RR HH24:MI:SSXFF'));
with this language settings
National Language Support
National
Language Parameter
Value
NLS_CALENDAR
GREGORIAN
NLS_CHARACTERSET
WE8MSWIN1252
NLS_COMP
BINARY
NLS_CURRENCY
€
NLS_DATE_FORMAT
DD.MM.RR
NLS_DATE_LANGUAGE
GERMAN
NLS_DUAL_CURRENCY
€
NLS_ISO_CURRENCY
GERMANY
NLS_LANGUAGE
GERMAN
NLS_LENGTH_SEMANTICS
BYTE
NLS_NCHAR_CHARACTERSET
AL16UTF16
NLS_NCHAR_CONV_EXCP
FALSE
NLS_NUMERIC_CHARACTERS
NLS_SORT
GERMAN
NLS_TERRITORY
GERMANY
NLS_TIME_FORMAT
HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT
DD.MM.RR HH24:MI:SSXFF
NLS_TIMESTAMP_TZ_FORMAT
DD.MM.RR HH24:MI:SSXFF TZR
NLS_TIME_TZ_FORMAT
HH24:MI:SSXFF TZR
I didn't see the error. Maybe somebody can help me.
Thx
Felix
Insert into ABC_123("dtstamp") values (to_timestamp('31.05.13 09:30:05,000748000 +01:00','DD.MM.RR HH24:MI:SSXFF'));
| | | | | | |
| | | | | | +--????
| | | | | +----SS
| | | | |
| | | | +-----MI
| | | |
| | | +-----HH24
| | |
| | +----RR
| |
| +----MM
|
+----DD
The error message means exactly what it says. Your data format string doesn't account for everything in your data string.
Maybe you are looking for
-
I just bought Adobe CS3 today but when I click on the install file, it does nothing. I have searched the web for help, but the one or two solutions I did manage to find seem far beyond me. I am on Windows Vista. Anyone have any solutions? Any respons
-
Hi Expert. I have a big problem. When I insert a query in a workbook this not sort by keyfigure. I insert a condition ( TOP 20 for example ). If I refresh a query in a workbook this sort correct but if I execute a workbook this is sorted by character
-
In trying to install Flash Player, the installation won't complete and I receive an error message saying Internet Explorer needs to be closed. I do not have any instances of IE open. How can I get the program to complete the installation?
-
Thunderbird will not keep new contacts in address book
I have added new contacts to my address book. When I go back a day later to use them they are gone. I have to recreate them to send an e-mail. Also I create a group contact and the same thing. I can use it the day I create it but the next day it is g
-
hi , i just got a new router.. but i am unable to get online...it gets no ip... i checked everything..even clone mac but that didn`t help either.. Firmware: v7.00.1