Working with Dates


Home Contents

Please email any bug reports, comments or suggestions to ExperLog's Online Support


Overview

In most cases, ExperShop uses long integers to store date/time informations: the main reason is that every database has its own Date formats, but every database can store long integers!

This way of handling dates is y2k compliant, of course, as ExperShop has been designed in 1999 (with current integer formats, a problem might occur in year... 2037, but in 2037 Integers should be wider than today ;)

Displaying dates in DynHtml templates

DynHtml includes a predefined data object, called "CurrentDate", that gives access to dates relative to the currend day.

For example, $CurrentDate:Now$ is the current day.

CurrentDate has the following attributes:

  • Now (the current time)
  • Day (the current day)
  • Month (the current month)
  • Year (the current year)
Dates can be formatted for display; example: $(DateFormat.yyyy:MM:dd)CurrentDate:Now$ will display the current year on 4 digits, then the current month and current day on 2 digits each, separated by ":" (September 15th 1999 would be displayed as "1999:09:15").

Formats are those defined in the java.text.DateFormat class, so you can also use the predefined DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG and DateFormat.FULL formats; Example, $(DateFormat.SHORT)CurrentDate:Now$ will display the current date in short format.

Dates can also be shifted, relative to the current time; for example, the following constructs are valid:

  • $CurrentDate:Day-1$ (yesterday)
  • $CurrentDate:Month+1$ (next month)
  • $CurrentDate:Year-2$ (2 years ago)
You can mix that with display formats: for example, to display on 4 digits the year that corresponds to 10 days ago, use $(yyyy)CurrentDate:Day-10$ (this will work, even between Jan 1st and Jan 9th).

Converting text to date values

The (DateVal) modifier can be used to convert a date text to an ExperShop date value (a long integer); the date text must be of the following format: yyyy:MM:dd (yyyy is the year, MM the month and dd the day).

For example, $(DateVal)1999:09:15$ will be converted to a long integer value that represents September 15th 1999.