Skip to Content
0

Date Format in SAP Business One SDK

Jul 31, 2017 at 06:09 AM

230

avatar image

Hello,

Greetings !!!

I am pasting Default date as Current Date on Tab of One of Control as follows

Public Function GetDateTimeValue(ByVal DateString As String) As DateTime
  Dim objBridge As SAPbobsCOM.SBObob
  objBridge = Main.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)
  Return objBridge.Format_StringToDate(DateString).Fields.Item(0).Value
End Function



Public Function GetDateToString(ByVal DateString As String) As DateTime
  Dim objBridge As SAPbobsCOM.SBObob
  objBridge = Main.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)
  Return objBridge.Format_DateToString(DateString).Fields.Item(0).Value
End Function

and Getting Error Message as Invalid Date Format.

Is there any other option for the same? Kindly suggest me.

Thanks,

Mahendrakumar

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
ANKIT CHAUHAN
Jul 31, 2017 at 10:32 AM
1

Hi,

To get the Date from the EditText, you can use as below:

SAPbouiCOM.EditText oEditStartDate = (SAPbouiCOM.EditText)oForm.Items.Item("StartDate").Specific;
SAPbouiCOM.EditText oEditEndDate = (SAPbouiCOM.EditText)oForm.Items.Item("EndDate").Specific;

SAPbobsCOM.SBObob objBridge = (SAPbobsCOM.SBObob)SBO_Company.GetBusinessObject(BoObjectTypes.BoBridge);
DateTime StartDate = Convert.ToDateTime(objBridge.Format_StringToDate(oEditStartDate.Value).Fields.Item(0).Value);
DateTime EndDate = Convert.ToDateTime(objBridge.Format_StringToDate(oEditEndDate.Value).Fields.Item(0).Value);

To Set the Date into an EditText, you can use as below:

oEdit = (SAPbouiCOM.EditText)oForm.Items.Item("txtDocDate").Specific;
oEdit.Value = DateTime.Now.ToString("yyyyMMdd");

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks a lot. Ankit

0