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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Current Date

BG_9641770
12-Amethyst

Current Date

Hi all 

 

what is best way to get mathcad to reference todays date?

 

I want to add a function that removes functionality of the sheet after day 6 months should another user try to access it. So will write a statement like the following 

 

If todays date is > 01/01/2022 then etc...

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:BG_9641770)

Here is an example of my last suggestion

Werner_E_1-1614255968809.png

 

 

View solution in original post

11 REPLIES 11
Werner_E
25-Diamond I
(To:BG_9641770)

Are you talking about real Mathcad or just Prime?
In Mathcad you could use a scripted component to get and return the current date.

In Prime you can use the time() function which gives you the number of seconds since 1.1.1970. You can now write a routine to get the current date using the number returned by time(0).

You can find solutions for both approaches by searching in this forum.

Another way is using an Excel component with the current date in a cell. Kind of using a sledgehammer to crack a nut 😉

For your purpose you won't need the current date, though. Simply add the number of seconds in six months to the result given by time(0) now. If the result of time(0) exceeds this number, its six months later. You may be generous and use 31 days for a month 😉

 

Hi its in Mathcad Prime 6.0.0.0

 

 

Werner_E
25-Diamond I
(To:BG_9641770)

So you can't use the first suggestion (scripted component).

But the other three still apply

can you upload an example sheets please 🙂 

 

sorry to be cheeky 

 

Thanks

 

Werner_E
25-Diamond I
(To:BG_9641770)

Here is an example of my last suggestion

Werner_E_1-1614255968809.png

 

 

Hi,

 

Enclosed is a number of date functions from the reference quoted at the top of the sheet.

They are a conversion from date functions from Mathcad.

Hope you can find them useful.

They will allow detecting passage of exactly 6 months.

 

Cheers

Terry


@terryhendicott wrote:

Hi,

 

Enclosed is a number of date functions from the reference quoted at the top of the sheet.

They are a conversion from date functions from Mathcad.

Hope you can find them useful.

They will allow detecting passage of exactly 6 months.

That's true, but for the purposes of the questioner, however, I guess it is essential to determine the current date and unfortunately I cannot find anything in the file for this. It is herewith added:

Werner_E_0-1614674904087.png

 

Since only the time () function is used here, the result is unfortunately limited to GMT (Universal Time UTC). Now I don't see any possibility of determining the time zone currently set on the computer without using a scripted component or an Excel component.

Hi,

 

As the date functions are used in a "included" worksheet referenced in when the functions are used you can for one time only at any site set a variable GMT to the + or - hour.  This would need to be reset if daylight saving or DS variable 0 or +1 is used in the file.  

 

Who wants to take up the challenge.

 

Cheers

Terry

This is a marvelous set of functions!

 

Express, however, will not accept programming.

 

Attached is a file that implements these functions in Express.  My thanks, Terry!

@Fred_Kohlhepp 

Looks like you have a wrong sign in the DaysBefore() function and this seems to be the reason why you had to change the Timebase to be two days off.

Werner_E_0-1614782001691.png

 

Thank you!  Good catch!

Announcements

Top Tags