David J Murray Dev
~ Learn and Do - Excel and Share ~

How to time travel with @DATE in UniVerse

Feb 28, 2011
Image by Pete Linforth from Pixabay
You're Reading: How to time travel with @DATE in UniVerse

Way back in Feb. 2008, I started to write this article about an interesting @DATE pass-by-reference issue – time traveling with @DATE in UniVerse.

Then I got sidetracked. So, this bug existed in whatever version was trial-ware at that time.

Guess what? It still exists in UniVerse on MS-Windows. So, here is how to time travel with @DATE.

Before we start, take this poll:

[poll id=”3″]


How to time travel with @DATE in UniVerse


I had found a problem with the SUBR call in a I-Type field definition within UniVerse. After testing, it appears to be within a BASIC program as well and is to do with the pass-by-value and pass-by-reference differences. So I thought.

The routine is passed a date, which I use @DATE as the default for this month. For other months or days, I would add or subtract 30,60,90 etc.


Within the routine, the date variable is changed – adding 1 or 2 days based on some simple calculations. What I found was that the system date was changing as well!

So, I have below two routines to test the theory:



print "S@DATE = ", @DATE, oconv(@DATE, "D4")
print "E@DATE= ", @DATE, oconv(@DATE, "D4")




    print "PDATE = ", PARAM1, oconv(PARAM1, "D4")
    print "@DATE= ", @date, oconv(@DATE, "D4")
    print "date() = ", date(), oconv(date(), "D4")

    PARAM1 += 1
    print "ADDED A DAY"

    print "PDATE = ", PARAM1, oconv(PARAM1, "D4")
    print "@DATE = ", @DATE, oconv(@DATE, "D4")
    print "date() = ", DATE(), oconv(date(), "D4")

    RESULT = 0


The output will be:

S@DATE = 15765, 28 FEB 2011
PDATE = 15765, 28 FEB 2011
@DATE = 15765, 28 FEB 2011
DATE() = 15765, 28 FEB 2011
PDATE = 15766, 01 MAR 2011
@DATE = 15766, 01 MAR 2011
DATE() = 15765, 28 FEB 2011
E@DATE = 15766, 01 MAR 2011

So, if you follow the PRINT statements, I start in the PROGRAM with 28 Feb, pass that through with @DATE as the parameter (pass by reference) and then added one day to it. The parameter within the subroutine changes to 1st March (PDATE) and also the date @DATE has also changed!

Since the parameter was passed by reference, the date (via @DATE) has also changed within the calling program (E@DATE).

If I change the passing of the parameter to pass-by-value by placing the parameter within brackets, the problem goes away.

If I change the passing parameter to DATE(), then the problem does not occur. So, what is the difference between @DATE and DATE()?


The difference between @DATE and DATE()


Well, I did discover something which I was not aware of: @DATE is the “internal date when the program was invoked”. This is from the UniBasic Reference documentation. I had always assumed that it was the system date now. Appears not! You learn something new everyday…

Time traveling with @DATE in UniVerse.

And DATE() “… return(s) the numeric value of the internal system date.” That makes sense. OK…

So, @DATE (and assuming that all derived @ values e.g. @DAY) are actually system variables that are created at the time of the program is invoked (run). And they are mutable. That is, they can be changed.

And this is all correct!

Oh, Yes. In the Appendix E of the UniVerse Basic Manual, there is a list of the @variables and “…denoted by an asterisk (*) are read-only. All others can be changed by the user.”

@DATE, @DAY, @MONTH and a whole bunch of others are mutable.

So, if you want to fudge your time sheets within your departments time-sheet software, in the next maintenance cycle, refactor to use @DATE and @TIME. Only joking, of cause.




So, recapping; DATE() is the CURRENT system date; @DATE WAS the date that the program was started, and if you started it late, you can change it. And all the subroutine parameter passing? Not really relevant; it was how I re-found the knowledge of @DATE.

Now, who can be honest here? How many readers thought that @DATE and DATE() were interchangeable?

And now?

[poll id=”4″]


About the Author

<a href="https://davidjmurray.dev/losucag/davidjmurray/" target="_self">djm</a>


I have been in the computer/IT industry for over 35 years. After spending half a life-time in highly proprietary database environments, I have succumbed to the WordPress Eco-system and I'm well down the chasm. I am specializing in AWS hosting, Wordpress CMS, Elegant Themes, in particular Divi and Extra themes.


Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This