UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Count Days, Access 2010    
 
   
mike60smart
post Jan 11 2017, 06:45 AM
Post#1


UtterAccess VIP
Posts: 12,203
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone


I have a subform where I am entering a Date into a Control named "TherapyDate" and I need to then calculate the number of days between the date entered and the Last day of Month

Any help appreciated.


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
Larry Larsen
post Jan 11 2017, 06:48 AM
Post#2


UA Editor + Utterly Certified
Posts: 24,100
Joined: 26-August 02
From: Melton Mowbray,Leicestershire (U.K)


Hi Mike

QUOTE
Last day of Month


Current month or the month of the date entered..?? [TherapyDat]
thumbup.gif

--------------------
"Time...We have exactly the same number of hours per day that were given to Helen Keller, Pasteur, Michaelangelo, Mother Teresa, Leonardo da Vinci, Thomas Jefferson, and Albert Einstein"
H. Jackson Brown
Go to the top of the page
 
mike60smart
post Jan 11 2017, 06:51 AM
Post#3


UtterAccess VIP
Posts: 12,203
Joined: 6-June 05
From: Dunbar,Scotland


Hi Larry

It will be month of the date entered

Sorry that should have read "TherapyDate"

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
Larry Larsen
post Jan 11 2017, 07:02 AM
Post#4


UA Editor + Utterly Certified
Posts: 24,100
Joined: 26-August 02
From: Melton Mowbray,Leicestershire (U.K)


Hi Mike

Have you looked at the DateDiff(..) function..

eg:
CODE
X= DateDiff ("d", [TherapyDate], DateSerial(Year([TherapyDate]), Month([TherapyDate]) + 1, 1))


thumbup.gif

--------------------
"Time...We have exactly the same number of hours per day that were given to Helen Keller, Pasteur, Michaelangelo, Mother Teresa, Leonardo da Vinci, Thomas Jefferson, and Albert Einstein"
H. Jackson Brown
Go to the top of the page
 
BruceM
post Jan 11 2017, 07:30 AM
Post#5


UtterAccess VIP
Posts: 6,822
Joined: 24-May 10
From: Downeast Maine


It would depend on whether you mean to count the starting date. To get the last day of the month you can use DateSerial to get the 0 day of the next month, which is the last day of the current month. That is, DateSerial(Year(Date()),Month(Date()) + 1,0) returns January 31, 2017.

The following, using January 30 as a hard coded date for purposes of illustration, returns 1 (January 31):

DateDiff("d",#2017/01/30#,DateSerial(Year(Date()),Month(Date()) + 1,0))

Use Larry's suggestion if on January 30 you want the result to be 2 (that is, count both the starting date and January 31).

I used January 30 and the Date function as an example, but it works the same way with TherapyDate or any other date value.
Go to the top of the page
 
mike60smart
post Jan 11 2017, 07:33 AM
Post#6


UtterAccess VIP
Posts: 12,203
Joined: 6-June 05
From: Dunbar,Scotland


Hi Larry

Works a treat as usual

Many thanks

cheers.gif

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
Larry Larsen
post Jan 11 2017, 09:21 AM
Post#7


UA Editor + Utterly Certified
Posts: 24,100
Joined: 26-August 02
From: Melton Mowbray,Leicestershire (U.K)


yw.gif

--------------------
"Time...We have exactly the same number of hours per day that were given to Helen Keller, Pasteur, Michaelangelo, Mother Teresa, Leonardo da Vinci, Thomas Jefferson, and Albert Einstein"
H. Jackson Brown
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    21st September 2017 - 07:50 PM