Tomorrow's date

Viewing 15 posts - 1 through 15 (of 30 total)
  • #94722

    Is there a function or a way to get tomorrow’s date?

    Ideally, I’d like to do something like this..

    today + 3 and then check if that date is part of the current month or not.

    Thanks,

    David

    #94725

    You can find the last day of the current month and check if it’s beyond:

     

    1 user thanked author for this post.
    avatar Bel
    #94726

    This is beautiful! How do I grab currentdate+3day’s date to compare to the max?

    #94728

    But I am not sure if this helps.. as I want a count of business days remaining in the month.

    #94729

    Current Year is YEAR

    Current Month is MONTH

    Current Day is DAY.

    If you need to extract the day from a date, say 20190326, then you’ll have to divide it by 1000000 (it’s a common number for Prt), then round it to the lowest integer, then multiply it by 1000000, then compute the difference between the date and the number you have got:

    d is the DAY number.

    #94730

    This is a link to my code to compute business days in a month https://www.prorealcode.com/topic/trading-in-giorni-specifici/#post-64933

    “Giornoferiale” means business day.

    #94731
    IF OpenMonth <> OpenMonth[1] THEN                                            //Se il mese della barra attuale è diverso da quello della barra precedente significa che siamo alla prima barra del mese…
      BusinessDay = 0                                                         //… per cui dobbiamo ricominciare da 0 a contare i giorni lavorativi
    ENDIF
    IF OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5 AND IntraDayBarIndex = 0 THEN   //Se siamo tra lunedì (1) e venerdì (5) ed è la prima barra del giorno…
       BusinessDay = BusinessDay + 1                                         //… significa che è iniziato un nuovo giorno lavorativo.
    ENDIF
    But how can I create a function that returns 3 when it checks today’s date 20190326?
    Using the above would give me the current businessday count for current date. Not sure how to get businessday count for last day of the month. if I had that value can do simple subtraction.
    #94733

    Sorry, my previous code was a divion (then multiplication) by 100, not 1000000!

    Just modify my previous DATE code:

    into Get MONTH:

     

    #94736

    It is not making sense. How can I combine what you’re providing to return the number of business days left in a month? Can you show me a function that takes today’s date 20160326 and returns 3. The same function should take tomorrow’s date and return 2.

     

     

    #94737

    day of the week number can be retrieved with: (Replace myYear,myMonth and myDay with YYYY, MM, DD number format. In this example it basically returns the day of the week of the current day.), I think that we could associate the snippets from Roberto to this one to know the last business day.

     

    #94738

    There’s no built-in function, by combining the above codes (extracting from dates) and business day math you can achieve that, but it takes a loop, since being 3 does not mean there have been 3 busniss days. PRT does not support easy date math (like eXcel does).

    You’ll have to start a loop from the day you want, then go backwords counting only those days whose dayofweek is between 1 and 5 to find out how many business day there were BEFORE that day.

    It’s not as straightfoward!

    #94739

    I cannot understand how to replace your ‘OpenDayOfWeek’ in the businessday logic.

     

    Is there a way to get the day of the week from the date?

     

    My temporary idea in pseudo code

    x = date

    DayMax = getDayMax(x)

    businessdayleft = 0

     

    for count = 1 to DayMax

    new date = x + count

    if dayNumber(newdate) > DayMax then break

    if getDayOfWeek(newdate) is business then increment bussinessdaysleft by 1

     

     

    // basically I need a dayNumber and dayOfWeek function unless I’m missing something?

    #94772

    we can use Nicolas’s solution for dayNumber, but am still unsure how to extract dayOfWeek

    #94776

    I’m working on it.

    #94795

    OpenDayOfWeek returns:

    1=Monday, … 5=Friday, so if any OpenDayOfWeek is within the range 1-5 it’s a business day (unless there’s some local holiday), so you can detect how many business days there are in each month by tallying from day 1 to the last day and skipping those ourside that range.

    Anyway, I attach 4 functions (they are actually indicators, but the behaviour is the same as in other languages, they may require parameters as their input and return some data):

    • DayMax                 (input: Month,Year                                                               returns: MaxDay)
    • IsLeapYear          (input: Year                                                                             returns: 1=leap year, 0=no leap year)
    • UnpackDate        (input: Date formatted as YYYYMMDD, as PRT does    returns: Day,Month,Year)
    • GetDayOfWeek  (input: Date formatted as YYYYMMDD, as PRT does    returns: 0=Sunday,1=Monday,….,6=Saturday)

    I attach both .ITF files to be imported into ProBuilder as well as .TXT files:

    Edit:     The above GetDayOfWeek function does not work fine, it has been replaced by a new version  (see post https://www.prorealcode.com/topic/tomorrows-date/page/2/#post-95272)

     

    2 users thanked author for this post.
Viewing 15 posts - 1 through 15 (of 30 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login