cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Date Calendar and Time functions.mcd

RichardJ
19-Tanzanite

Date Calendar and Time functions.mcd

Here is a selection of functions for dates, calendars, and times. Also included is a calendar component that allows a date to be selected by the user. The scripted components were all written by me, but the additional functions at the end of the worksheet were not. In fact, I don't know who did write some of them, but if the author of those functions, or someone who knows who the author is, reads this then please let me know who did write them so I can credit them correctly.

Jun 09 2015: Added a worksheet for Mathcad Prime. This includes only the limited set of functions not based on scripted components.

21 REPLIES 21

does it contain some excel objects. As i'm seeing weird images in the file.

Using Mathcad 14.0.0.163

RichardJ
19-Tanzanite
(To:RichardJ)

No. It contains two functions written as scripted components though. Those functions are based on ClipArt objects (for no particularly good reason - just a whim), so perhaps that is what you are seeing.

it would be nice if i can extract the individual parts from CurrentDateAndTime function.

for eg.

CurrentDateAndTime("Year") should give me just the year part in integer not string so i can perform calculations on them.

Also in your question how many days have passed since start of year. it should automatically pick the start of the year. rather than having me enter it manually. So is the date is in 2003 it should automatically pick 1/1/2003.

RichardJ
19-Tanzanite
(To:RichardJ)

it would be nice if i can extract the individual parts from CurrentDateAndTime function.

for eg.

CurrentDateAndTime("Year") should give me just the year part in integer not string so i can perform calculations on them.

I added two more functions

Also in your question how many days have passed since start of year. it should automatically pick the start of the year. rather than having me enter it manually. So is the date is in 2003 it should automatically pick 1/1/2003.

That's also taken care of by the new functions.

thanks richard this is great addition

i think if just a time is given it should be assumed to be current date rather than dec 1899

Oh the second term in split function is quarter. hmmm

MikeArmstrong
5-Regular Member
(To:RichardJ)

The attached image just sank my computer when trying to open.

If saved on my hardrive the image cannot be seen.

Mike

it was my mistake. there is nothing wrong with the function. I didn't realize that the second term is a quarter not month.

btw how did you manage to show your SplitDate function as (2010 1 2 4 X X X X)

mine is showing as a table. is that an alternative way to show a vector.

MikeArmstrong
5-Regular Member
(To:RichardJ)

Double left click on the result of the function, select "Display Option" tab and change the matrix display style to a Matrix.

Mike

RichardJ
19-Tanzanite
(To:RichardJ)

The attached image just sank my computer when trying to open.

If saved on my hardrive the image cannot be seen.

What image are you talking about?

MikeArmstrong
5-Regular Member
(To:RichardJ)

I'm not going mad.........Am I?????

Think Ziyad removed it

Mike

RichardJ
19-Tanzanite
(To:RichardJ)

i think if just a time is given it should be assumed to be current date rather than dec 1899

I don't much care for that behavior either, but I'm just hijacking a VBscipt function, and that's the way it works. The only way I could fix it would be to do a fair amount of string handling or regular expression matching to trap the case when there is only a time. Too much work. Sorry.

thats fine Richard. I don't want to impose a hard solution for a small problem.

you have already helped me alot with date stuff.

Thank you

Did you get time to change SplitDate function to be able to use a vector of dates

RichardJ
19-Tanzanite
(To:RichardJ)

Did you get time to change SplitDate function to be able to use a vector of dates

Sorrry, not yet. It turned into a very busy weekend. I will try and get to it tomorrow.

RichardJ
19-Tanzanite
(To:RichardJ)

OK, I have uploaded a new version of the document. SplitDate and AssembleDate now handle multiple dates at one time.

For completeness, I also added the functions form here:

http://communities.ptc.com/docs/DOC-1431

to the end of the document.

Very helpful.  Thanks

StuartBruff
23-Emerald II
(To:RichardJ)

Neat.  Good work.

RichardJ
19-Tanzanite
(To:RichardJ)

Neat.  Good work.

Thanks. I just felt my head swell slightly

Richard,

Your worksheet on dates does show where some of the functions came from.  One Terry Hendicott who does not claim creation but lists the book that they came from.  They are a translation from C++ functions in the reference.

Glad to see contributions are reused - refined and upgraded.

Cheers.

StuartBruff
23-Emerald II
(To:RichardJ)


@RichardJ wrote:

Here is a selection of functions for dates, calendars, and times. Also included is a calendar component that allows a date to be selected by the user. The scripted components were all written by me, but the additional functions at the end of the worksheet were not. In fact, I don't know who did write some of them, but if the author of those functions, or someone who knows who the author is, reads this then please let me know who did write them so I can credit them correctly.

 


This need for speed ... sorry, date-time in Prime ... cropped up again, recently.

 

https://community.ptc.com/t5/PTC-Mathcad/Date-update-in-Mathcad-Prime/m-p/763808#M198782

https://community.ptc.com/t5/PTC-Mathcad/Current-Date-in-Mathcad-prime/m-p/763761#M198774

 

To cut a short story long, in response to the OPs, @VladimirN posted Original Mathcad worksheets containing some date and time functions.  However, as an Express-only user, I couldn't do much with them.   Then, over the weekend, I remembered that I'd converted my old worksheet collection into Prime the last time I had a trial licence, and found a similar-looking file.   So, I had a brief look at Expressifying it.   

 

I then looked for a suitable home for the resulting worksheet and found this thread, which looks like the source of the original material.   So, @RichardJ @terryhendicott , еще раз спасибо for the originals.

 

And еще раз, I lament the inability to hide quote marks in Mathcad strings ... or to have a handy selection of symbols that numerically evaluate to themselves (apart from decimal digits and NaN (*) - ISTR that π in the units placeholder would stay as π in M15?

 

As proof of the (soon-to-be-Christmas) pudding, here's a 2022 Mathcad calendar.

2021 12 20 a.png

 

And by way of Благодарность to Vladimir, 

2021 12 20 b.png

 

Stuart

 

(*) Why, oh why, oh why, do we еще, in this day and age, have infinity defined as 10^308 instead of a proper IEEE ∞ represented as such? 👿

 

Are there any other major maths applications where infinity is less than the maximum representable number?

2021 12 20 b.png

Which millions of fee-paying customers are going to be taking to the streets with pitchforks and baying for blood because their myriads of worksheets depend upon 10^308 and no workaround (like automatic conversion upon loading) will suffice?   Not the ones using symbolics, I imagine ...

 

And, yes, I do declare today as International Snarkiness Day because I've been bitten yet again by lack of a proper infinity and by the 15-decimal-place restriction.  I hope, as a mark of solidarity, you all mark it as such in your Mathcad Calendars.  😈

Top Tags