I apologize first hand if haven't understood your question clearly. Is your question "how to compare two dates?" or "how to write code in the code block?". I can give a jsp(Java) example(The script-type is set to VoiceXML-jsp in Tools->Options in studio menu):
1. Open any block you want to put your code in.
2. Click on the Edit button which will open an editor.
3. You may have to include classes as necessary in the beginning of the code block.
4. You can put in your code in processBegin(PageContext), processAnywhere(PageContext) or processEnd(PageContext).
(I would suggest you move these utility code snippets to a support file or similar so you can just call the function from anywhere in the Studio code and helps eliminate redundancy. You can even create your own library of such stuff and put them in your server's library.)
<%@ page language="java" import="java.util.Date"%>
<%@ page language="java" import="java.text.SimpleDateFormat"%>
<%!
// localPageContext - Contains the reference to the Page Context.
// Can be used o Access the HTTP Objects
//Can be used for writing the custom code that needs to get
//executed before the vxml page starts
public void processBegin(PageContext localPageContext){
String DATE_FORMAT = "yyyy-MM-dd";
java.text.SimpleDateFormat sdf =
new java.text.SimpleDateFormat(DATE_FORMAT);
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.set(2008, 10 , 31);
cal2.set(2001, 11 , 30);
//System.out.print(sdf.format(cal1.getTime()));
if (cal1.before(cal2)) {
System.out.print(" is before ");
}
if (cal1.after(cal2)) {
System.out.print(" is after ");
}
if (cal1.equals(cal2)) {
System.out.print(" same as ");
}
}
//Can be used for writing the custom code that needs to get
//executed before the vxml page ends
public void processAnywhere(PageContext localPageContext){
}
//Can be used for writing the custom code that needs to get
//executed after the vxml page ends.can be used for doing cleanup
public void processEnd(PageContext localPageContext){
}
PS: I used to work on a different platform before that provided all the APIs for these kind of stuff. But the cool thing here is you can build your own stuff which is very easy coz it Java, ASP etc(you can easily google and get examples on how-to's).