Skip to Content

Date Format in SAP Business One SDK

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jul 31, 2017 at 10:32 AM

    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

    Add comment
    10|10000 characters needed characters exceeded