Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


How to get number of days in the current month or last day of the current month


fuser99

Recommended Posts

 

Hi,

 

I'm trying to figure it out how to get the last day of the month in order to know if the current month has 28, 30 or 31 days but I was unable to and I couldn't find a solution in the forum.

Could someone point me in the right direction?

Thank you in advance.

 

 

 

Link to comment
Share on other sites

  • Topic Author
  • 15 hours ago, SmartHomeEddy said:

    I found something like this:

     

    Please login or register to see this code.

     

    It works great. Thank you.

    I was thinking if there's a function already implemented in Fibaro HC3.

     

    Link to comment
    Share on other sites

    5 hours ago, fuser99 said:

    I was thinking if there's a function already implemented in Fibaro HC3.


    Cannot imaging that. Why do you want to know the maximum days? 

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, SmartHomeEddy said:


    Cannot imaging that. Why do you want to know the maximum days? 

     

    I need this in order to be able to project monthly usage of a power meter based on how much did it "use" till now as daily average.

    For example if today is 6th of September and the meter is 876 we know September has 30 days, so the projection would be 876/6 (daily avg) * 30 (days in current month). Perhaps is a better alternative for that,but I don't know yet. Also I need to do some processing on that data on last day of each month at 23h59m.

    This could be also used for energy consumption and/or solar panel production. Having better history would help me project better calculations in the future, especially for solar power production.

     

    • Like 1
    Link to comment
    Share on other sites

    Maybe using this function from Richard Warburton:

    Please login or register to see this code.

    It uses LUA built in functions and it support leap year, but year must be provided.

    Added time formatting as a bonus :-)

    Edited by Sankotronic
    Corrected code
    • Like 2
    Link to comment
    Share on other sites

  • Topic Author
  • Wow. That's amazing! Tested and seems to be working - I'll do more tests in the upcoming days.

    Thank you.

     

    Please login or register to see this code.

     

    "{}" should be replaced with "()".

    Link to comment
    Share on other sites

    On 9/29/2022 at 1:01 PM, fuser99 said:

    "{}" should be replaced with "()".

     

    Thanks and done.

    • Like 1
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...