Skip to Content
author's profile photo Former Member
Former Member

validate & format date

I have to read a date from a form (my form). I'd like to know how can I validate if the date is a correct format and how to transform the date (which will be supplied in dd/mm/yyyy format to mm/dd/yyyy, that i need in a stored procedure on sql server).

Thank you,

Irina

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2005 at 11:12 AM

    Hi, Irina!

    If you use UserDataSource for the item on your form you must use DataType = BoDataType.dt_DATE

    Set oForm = SBO_Application.Forms.Item("MyForm")

    oForm.DataSources.UserDataSources.Add "MyDate", BoDataType.dt_DATE

    Set oEditText = oForm.Items.Item("DateEditText").Specific

    oEditText.DataBind.SetBound True, "", "MyDate"

    Alex

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2005 at 08:04 AM

    I would say that depends on your programming language of choice. For example, in C#, I could change the date format like this:

    String olddate = "20/12/2005"; //Change to actual date

    String day = olddate.Substring(0,2);

    String month = olddate.Substring(3,2);

    String year = olddate.Substring(6);

    if (int.Parse(month) > 12) throw new Exception("Month out of range");

    //Have additional tests..

    String newdate = month"/"day"/"year;

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2005 at 09:12 AM

    Try this code.

    DATA c_date TYPE sy-datum.

    DATA v_date(10).

    INITIALIZATION.

    c_date = sy-datum.

    WRITE c_date TO v_date.

    Here you will get the date as string in v_date & 'WRITE' statement converts it to sy-datum format. then you can validate it.

    Regards,

    Hemant

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.