# Thread: First day of next month from today

1. ## 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. ## RE: First day of next month from today

Stan,

This might be easier:

I tested it, and it works fine.

Tom Henkel

3. ## 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. ## 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:

day({dateexp}),0,day({dateexp}-1),1)

try it and let me know.

Tom

5. ## RE: First day of next month from today

also handles year changes

6. ## RE: First day of next month from today

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

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. ## 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

Regards,

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

8. ## 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. ## RE: First day of next month from today

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

the formula should look like this:

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

#### Posting Permissions

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