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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

11-Garnet

## 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...

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:BG_9641770)

Here is an example of my last suggestion

11 REPLIES 11
24-Ruby V
(To:BG_9641770)

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 😉

11-Garnet
(To:Werner_E)

Hi its in Mathcad Prime 6.0.0.0

24-Ruby V
(To:BG_9641770)

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

But the other three still apply

11-Garnet
(To:Werner_E)

sorry to be cheeky

Thanks

24-Ruby V
(To:BG_9641770)

Here is an example of my last suggestion

21-Topaz I
(To:Werner_E)

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:

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.

21-Topaz I
(To:Werner_E)

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

23-Emerald I
(To:terryhendicott)

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!

24-Ruby V
(To: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.

23-Emerald I
(To:Werner_E)

Thank you!  Good catch!

Announcements
Top Tags