Alpha Video Training
Results 1 to 9 of 9

Thread: First day of next month from today

  1. #1
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default First day of next month from today

    If anyone needs this, as I did today........


    ctod(if(month(date())<12,alltrim(str(month(date())+1)),"01")+"/01/"+if(month(date())<12,right(alltrim(str(year(date()))),2),right(alltrim(str(year(date())+1)),2)))

    Any date variable could be used in place of the date() function to return the first day of the month after the value of the date variable.

  2. #2
    Thomas Henkel
    Guest

    Default RE: First day of next month from today

    Stan,

    This might be easier:


    addmonths(date()-(day(date()-1)),1)

    I tested it, and it works fine.

    Tom Henkel

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: First day of next month from today

    Tom,

    I think that's close but I tested using a date variable and when the date variable is set to the first day of a month (say 10/01/01) then day(date()-1) drops back to the previous month and the whole expression results in the first day of the current month.

    Did cause me to reconsider the addmonths() function, though. Thanks for the suggestion.

  4. #4
    Thomas Henkel
    Guest

    Default RE: First day of next month from today

    You may just want to test if day({dateexp}-1)> day({dateexp}),0,day({dateexp}-1)

    ie:

    addmonths({dateexp}-if day({dateexp}-1)>
    day({dateexp}),0,day({dateexp}-1),1)

    try it and let me know.

    Tom

  5. #5
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,956

    Default RE: First day of next month from today

    tdate=ctod(str(month(addmonths(date(),1)),2,0) + "/01/" + str(year(addmonths(date(),1)),4,0)) ->renders {11/01/2001} if today is {10/29/2001}

    also handles year changes

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: First day of next month from today

    John Zaleski sent me what looks to be the most compact solution......


    addmonths(datevar - day(datevar) + 1,1)

    Additionally

    datevar - day(datevar) will result in the last day of the previous month and

    datevar - day(datevar) + 1 will result in the first day of the current month, if those are needed.

    Thanks for everyone's input.

  7. #7
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default RE: First day of next month from today

    Sorry Tom, but your expression fails on the 1st day of each month, although you had the right basic idea. This is a correct expression

    addmonths(date()-day(date())+1,1)

    Regards,

    Ira J. Perlow
    Computer Systems Design & Associates
    csda@mediaone.net

  8. #8
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default RE: First day of next month from today

    For some reason, my browser did not show me the other posts, and thus what I just said is obviously redundant...redundant.

    Regards,

    Ira J. Perlow
    Computer Systems Design & Associates
    csda@mediaone.net

  9. #9
    Thomas Henkel
    Guest

    Default RE: First day of next month from today

    Sorry, Guys,
    There was an inappropriately placed right paren.

    the formula should look like this:

    Addmonths(date()-(day(date())-1),1)

    The day(date())-1) will yield "0" if it is the 1st of the month, making the subtraction 1-0 = 1.

    This time I tested it with 01/01/2002, and it works fine.

    Tom Henkel

Similar Threads

  1. PC TODAY Dec 2004 Alpha Five vs MS Acess
    By Richard Rabins in forum Announcements
    Replies: 2
    Last Post: 12-06-2004, 11:05 AM
  2. today()
    By Cindy731 in forum Alpha Five Version 5
    Replies: 3
    Last Post: 10-07-2003, 05:48 AM
  3. VER 7 Official released today.
    By Ken Fleming in forum Alpha Four Version 6 and Prior
    Replies: 1
    Last Post: 11-08-2001, 12:45 PM
  4. From Today to End Date
    By Keith Hubert in forum Alpha Five Version 4
    Replies: 3
    Last Post: 05-22-2001, 12:26 PM
  5. SIMPLE? not today
    By Aamer Khan in forum Alpha Five Version 4
    Replies: 5
    Last Post: 06-25-2000, 10:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •