cancel
Showing results for 
Search instead for 
Did you mean: 

RfcDateToDateTime

Former Member
0 Kudos

Hi

Anybody knows how to use the RfcDateToDateTime?

Im displaying my data on a Datagrid. The date field shows 'YYYYMMDD'. I do not wish to display the data as such format.

Anybody could me show how to display the date field in this format: 'dd/mm/yyyy'?

I come across about the RfcDAteToDateTime but I do not know how to use.

Thank you.

Regards.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

This static function takes a string which represents a date in the SAP Applications format and returns a DateTime .NET type. Use this type as you wish.

For the format you requested you can write this (C#):


using SAP.Connector;

...

label1.Text = "19950125";
DateTime dt = RfcConvert.RfcDateToDateTime(label1.Text);
label2.Text = dt.ToString("dd/MM/yyyy");

Regards,

Ofer

Former Member
0 Kudos

Thanks Ofer.

Yup, it do help also when you want to display the data in textbox.

But how about in the DataGrid itself?

How do I format my data while on the Datagrid?

Thank you.

Regards.

Former Member
0 Kudos

Hi,

Well, I'm not a DataGrid expert... But -

there are several options here, and a simple way (depending on you code) is to call this convert function in a "foreach" loop on all rows of the table in the proxy. You can put this code right after the rfc function.

You code should look something like:

(I assuming you have a function that returns a Table and the table row is of type MY_STRUCT. You also have a field called "Result" in the proxy that is mapped to this table. )


foreach (MY_STRUCT row in this.sapProxy11.Result)
{
  row.Date  = RfcConvert.RfcDateToDateTime(row.Date);
}

Maybe not pretty, but should work.

Regards,

Ofer

Former Member
0 Kudos

Thanks Ofer.

It works. Modify abit to suit VB.net codes.

Thanks.

regards.

Former Member
0 Kudos

You are welcome

Please mark the question as answered, so others can see

(this is done by clicking on the stars next to the post that answered your question or helped you).

Regards,

Ofer