How to get the days in and date difference.

webweb Member Posts: 102
Hi,
I am subtracting between to dates. I get something like 30.65. 30 is in months and .65 in days.
I am trying to add a logic that will take this on board.
from 0-20 days should be 0 month and 21 above should be 1 month.
Can anyone help me with this please.
Thanks

Comments

  • DenSterDenSter Member Posts: 8,305
    web wrote:
    I am trying to add a logic that will take this on board.
    I don't understand, are you in a boat? Could you explain what you need without using slang?
  • webweb Member Posts: 102
    I mean how can i take the decimal part of my date difference which is i months and day( i.e 30.40) to have the decimal which is days to take 0-20 day to 0month and 21 above to 1 month.
    I hope this is clear?
    Thanks
  • EugeneEugene Member Posts: 309
    this is not clear
    what exactly your 30.40 means ?
    30 months and 40 days ?
    does 30 months mean 30*30 days ? do you want your month to be 20 days long so that 30 months is equal to 30*20 days ?
    explain to us what format you are using
  • DenSterDenSter Member Posts: 8,305
    I'd probably multiply the decimal by 100, then put it into a text variable, copy the last 2 digits, evaluate that into an integer, and then create a little function that looks at the value and returns 0 or 1 depending on the value.

    I'm still unclear about the decimal though. Your example was 30.65. Taking the decimal part out of that you'd have 65, which in calendar days would be well over two months. By your logic it would be just 1 month, because it's higher than 21. How are you going to handle that?
  • kolaboykolaboy Member Posts: 446
    The number of days in a month will be exactly as in the respective months. But where we have .17 needs to be converted to days and if it is ,21 days it returns zero otherwise it should return 1 month.
    sorry for giving .65 as example. it is really a bad example i gave. So for bothering you because i am learning programming.
    Thanks
  • XypherXypher Member Posts: 297
    If you're trying to extract decimal or whole number use the following,
    Variable1 DIV Variable2 := WholeNumber;
    
    Variable1 MOD Variable2 := FloatingPointNumber;
    
Sign In or Register to comment.