on 10-08-2008 3:53 PM
I have a string field length of 6 for both date and Time :
Field1 stores the date as 100808
Filed2 stores the time as 1000
I need to convert and print as acceptable dates. ie 10/08/2008 and 10:00am
Any help is appricated..
Jim
James,
Try the following formula;
stringvar d:= '100808'; //or database field
stringvar t"= '1000'; //or database field
numbervar y:= tonumber ( '20' & d[5 to 6]);
numbervar m:= tonumber ( d[1 to 2] );
numbervar dd:= tonumber ( d[3 to 4] );
numbervar h:= tonumber ( t[1 to 2] );
numbervar mm:= tonumber ( t[3 to 4 );
datetime( y, m, dd, h, mm, 0)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry guys, with the following
;
stringvar d:=; //or database field stringvar t"= ; //or database field
numbervar y:= tonumber ( '20' & d5 to 6);
numbervar m:= tonumber ( d1 to 2 );
numbervar dd:= tonumber ( d3 to 4 );
numbervar h:= tonumber ( t1 to 2 );
numbervar mm:= tonumber ( t[3 to 4 );
datetime( y, m, dd, h, mm, 0)
it highlights the d5 in the 3rd Line and says
a number, currency amount, boolean, date, time, date-time, or string is expected here
stringvar d:= {TAGDTL.USER_DEF_TEXT_1}; //or database field
stringvar t:= {TAGDTL.USER_DEF_TEXT_2}; //or database field
numbervar y:= tonumber ( '20' & d[5 to 6]);
numbervar m:= tonumber ( d[1 to 2] );
numbervar dd:= tonumber ( d[3to 4] );
numbervar h:= tonumber ( t[1 to 2] );
numbervar mm:= tonumber ( t[3 to 4] );
datetime( y, m, dd, h, mm, 0)
Thanks for all your help.. The trim functions was part of the answer. I ended up paying for support, took about 50min with support to figure out what to do to fix the problem so it was worth it.
Jim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The date part is working however the time was causing errors so I have seperated the values out to two differnt displays. As I stated the date is file here is the problem with the time field.
it is a string of 6 characters the informtion is stored as ' 1100 ' without the quotes so I have a space in the front and the back. here is my formula
stringvar t:= {TAGDTL.USER_DEF_TEXT_2}; //or database field
numbervar h:= tonumber ( t[1 to 3] );
numbervar mm:= tonumber ( t[4 to 6] );
time(h, mm, 0)
and now I get the following error while the time(h,mm,0) is highlighted
Minutes must be between 0 and 59
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I forgot to say I tried that. 2:3 and 4:5 however it still gets the same error. I also looked to see if there was any bad data ie. blanks and the data is clean... Still get the same error message. this one has got me so bad, I have paid for a support call and am waiting for a response.
Edited by: James Fulton on Oct 9, 2008 5:58 PM
Hello James,
this might help you, (direct from the help file of crystal)
//Crystal syntax
Local StringVar s := GroupName ({Orders.Order Date}, "monthly");
If IsDate(s) Then
CDate(s)
Else
CDate(0,0,0)
Returns the Date value May 1, 1998 if the GroupName field value is "May - 1998". Returns the null Date (a non-printing Date value) if the GroupName field value is "Others".
Comments
This function is similar to the Visual Basic function of the same name, except that it works specifically with Crystal Report's Date type which holds date values only.
Regards
Jehanzeb
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.