Skip to Content

Current Date in XML View

Hi Experts.

I was developing my first view in UI5 a while ago and I did it using JavaScript.

As soon as I was enjoying it I started to look for best practices and patterns and started to develop in XML.

My first view had two fields that were populated by two oDatas, one with months and the other with years and in Javascript I was able to filter it using some functions and populate the two field with the current month and year.

I want to know how to do it in XML.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 09, 2015 at 10:30 AM


    I also don´t know a way to directly do this in the XML view. I think this it is not possible.

    However you can set a model in the controller:

    var oModel = new sap.ui.model.json.JSONModel({currentMonth : new Date().getMonth()});

    and then bind a field in the view to that model:

    <Text text="{/currentMonth}"/>

    The same you can do for the current year.

    This worked for me.

    Best regards,


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 08, 2015 at 08:10 PM

    do the same in your controller

    it is not in the xml.

    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.