Solved Get date of first day of month from another control (1 Viewer)

foshizzle

Registered User.
Local time
Today, 01:40
Joined
Nov 27, 2013
Messages
277
I have two unbound text box controls on a form; txtStartDate and txtEndDate.
I would like the user to only enter a value for txtEndDate. How would I get the date for the first day of the month (based on the date in txtEndDate) and populate it in txtStartDate?

I believe the below gets me the first day of the current month. I'm not sure how to make this work for the value of another text box though...

=Dateserial(year(date()), month(date()),1)
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:40
Joined
Aug 30, 2003
Messages
36,124
Just refer to the textbox instead of using Date():

=Dateserial(year(Forms!FormName.TextboxName), month(Forms!FormName.TextboxName),1)
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:40
Joined
May 21, 2018
Messages
8,525
And if you ever want the last day of the month
Code:
=Dateserial(year(Forms!FormName.TextboxName), month(Forms!FormName.TextboxName)+1,0)
add one to the month and set the day to 0
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:40
Joined
Aug 30, 2003
Messages
36,124
Happy to help!
 

Users who are viewing this thread

Top Bottom