The macro to do date difference in years months days.

classic Classic list List threaded Threaded
1 message Options
Michael D. Setzer II Michael D. Setzer II
Reply | Threaded
Open this post in threaded view
|

The macro to do date difference in years months days.

This is the macro for the date to years months day.
Hopefully this posts ok without changes..


sub Z3
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim sText
sText = InputBox ("Please enter Date Cells Example D2,D1:")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "StringName"
args1(0).Value = "=IF(DATEDIF(" & sText & ",""y""),IF(DATEDIF(" & sText &
",""y"")=1,""1 Year "",DATEDIF("& sText & ",""y"")&"" Years
""),"""")&IF(MOD(DATEDIF(" & sText & ",""m""),12),IF(MOD(DATEDIF(" &
sText & ",""m""),12)=1,""1 Month "",MOD(DATEDIF(" & sText &
",""m""),12)&"" Months ""),"""")&IF(DATEDIF(" & sText &
",""md""),IF(DATEDIF(" & sText & ",""md"")=1,""1 Day "",DATEDIF(" & sText
& ",""md"")&"" Days""),"""")"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args1())

end sub


+------------------------------------------------------------+
 Michael D. Setzer II - Computer Science Instructor (Retired)    
 mailto:[hidden email]                            
 mailto:[hidden email]
 Guam - Where America's Day Begins                        
 G4L Disk Imaging Project maintainer
 http://sourceforge.net/projects/g4l/
+------------------------------------------------------------+




--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy