When I input a value for a Date Variable, Corvid does not accept it. Different regions of the world use different formats to represent the date and time. For example, the U.S. uses 3/7/02, Australia uses 2002-Mar-07, the U.S. Military uses 20020307, and Yugoslavia prefers Thursday, 7. March 2002. The end user specifies how they want programs to format the date and time by specifying the format in their Regional Settings, which is in the Control Panel. Normally this is done when they install the Windows Operating System but it can be changed at any time. When Corvid displays a date and/or time to the end user, it will format it as they specified in their Regional Settings. When Corvid asks the user for the date and/or time, they must enter the date and/or time in the same format that is specified in their Regional Settings. Java supports both "Short" and "Long" forms of dates for each setting. Corvid will try both formats to see if the input strings match. Date formats are quite dependent on the localization of Java. By default, U.S. users must enter the month number, a slash, the day number, a slash, and the year as 2 digits. For example: 3/7/08. Corvid also allows 4 digit years and leading 0s for month and day. For example: 03/07/2008. When asking the user to input a Date variable's value, Corvid will expect the date to match their Regional Settings. Corvid also uses the Regional Settings to display Date variables' values. A problem occurs with Corvid running as an applet when the date value did not come from the end user but came from a database or data file from the server and the format does not match the user's Regional Settings. To solve this problem, use the International data format for all data values not supplied by the user. The International date format is always the same regardless of your regional settings or locale. It is the format used by many databases such as MySql. It is the format you should use for dates that are not assigned by asking the user. The format is:
where "YYYY" is the 4 digit year, "mm" is the two digit month and "dd" is the two digit day. If the month or day is only one digit, insert a leading "0" to make it two digits. The time can be included using this format:
where "hh" is the two digit hours and "MM" is the two digit minutes and "ss" is the two digit seconds. You can include milliseconds by using this format:
where "mmmm" is the 4 digit milliseconds. Always use the International date format for hard coded (literal) dates. For example:
The DATE function converts the string into a Date which is assigned to the Date variable in a THEN node or compared to the Date variable in an IF node. Corvid tries to interpret the date from the text representation by trying these in order:
Handling dates in systems that are international can be difficult due to the different date formats. In many cases, if the system does not require an actual date calculation in the logic, it is better to use a String variable rather than a Date variable. The string will accept any format and if it is just being added to a report, the string will work well. In other cases, it is better to use separate variables and controls for day/month/year and then use those to set the value for the Date variable as needed. |