cancel
Showing results for 
Search instead for 
Did you mean: 

String field to Data coversion

Former Member
0 Kudos

Hi,

I want to convert the string field to data format.I tried the option cdate(table.field)

but once again it is throwing an error saying"Formula must be string"

so i gave cstr(cdate(table.field)) but i am getting the value as 4/5/2008

but in the db it is 04/05/2008

Any suggestions

Regards,

Rajasekar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You want to convert string value to date value.

You are using cdate function here which would do the job however cstr function again converts it into a text.

Would suggest you to modify the formula like this

if isdate(databasefield) then cdate(database field)

here isdate function will check weather the database field value can be converted to a date value.

Place this formula on report and right click it and click on Format Field.

Under the Date tab select the format as 03/01/1999.

Click OK and it will show the required results and the value returned will be a date value as well.

Regards,

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Rajasekar,

Try to create a formula like :

Numbervar dd;

Numbervar mm;

Numbervar yy;

dd:=tonumber(left({Sheet1_.dt},2));

mm:=tonumber(mid({Sheet1_.dt},4,2));

yy:=tonumber(right({Sheet1_.dt},4));

datevalue(yy,mm,dd);

Once you get the value in your report use format option and apply the format '02/12/2008'

Hope this will resolve the issue.

Regards,

Sastry

Former Member
0 Kudos

I tried this but i am getting an error saying the "formula must be string"

Also tried to create two formula

@F1=Tbl.field

@F2=Cdate(@@F1)

Now i am getting the data format as 01/01/2008,but i have a requirement to change this date based on the user preferences from main report.

I have a variable in main report which stores the user preferences,i need to use that variable and have to change the sub report date format.

The user may give the date format as 12 Sep 2008 i need to get my subreport date also based on this but i am getting 2008/9/12

Any suggestions

Regards,

Rajasekar

Former Member
0 Kudos

What is the variable value that user enters ? If you have any static/standard value in the variable then based on the value we can format the date.

Regards,

Sastry

Former Member
0 Kudos

I have a combo field where in i have the date format like

1.dd/mm/yyyy

2.dd-mm-yyyy

3.dd mon yyyy

Like this i have the date formats

The user may select any one of these format then i need to display that format in the sub report.