Date and Time in Meta-SQL

Similar to the article on date and time in PeopleCode this article covers working with date and time in Meta-SQL.

The Meta-SQL date/time constructs you should know about are:

For input/output of the current date/time:

  • %CurrentDateIn
  • %CurrentDateOut
  • %CurrentDateTimeIn
  • %CurrentDateTimeOut
  • %CurrentTimeIn
  • %CurrentTimeOut

For input/output of any date/time:

  • %DateIn
  • %DateOut
  • %DateTimeIn
  • %DateTimeOut
  • %TimeIn
  • %TimeOut

Remember that:

  • input date/time goes in the WHERE clause (conditions)
  • output date/time goes in the SELECT clause (returned data)

For input/output of a null date/time:

  • %DateNull
  • %DateTimeNull
  • %TimeNull

For getting part of a date/time:

  • %DatePart gets the date
  • %TimePart gets the time

For date arithmetic:

  • %DateAdd(from, days_to_add) gives the resulting date. You can use negative numbers to get a past date. So this is also the DateSubtract function.
  • %DateDiff(from, to) gives the difference between two dates in days
  • %DateTimeDiff(from, to) gives the difference between two date/times in minutes
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License