A067CB8C3CE34925B5C7022ED4B01104
  • RedDot CMS Blog
  • 20.12.2019
  • EN

rdb: Date decoding/encoding

Taken from the RQL Documentation regarding Date Conversion:

In CMS, date information is always given as a floating point number or as an integer. A floating point number includes that date and time, whereas the integer only contains the date.

Here is how you convert a number into a date.

The simplest way to convert a number into a date, is to use CMS objects. Bind the DecodeDate function into your source code.

Below is an example of how your code might look:

' From an RQL assign a value to a variable
OldDate = EinObjekt("changedate")
' Convert value by calling the DecodeDate function
' and output in both variants.
response.write "Date from attribute=" & OldDate & " --> Convert date=" & DecodeDate(OldDate)
Function DecodeDate(OldDate)
   Dim objIO As Object ' Define object
   Set objIO = CreateObject("RDCMSAsp.RDPageData") ' Create object
   DecodeDate = objIO.decodedate(OldDate) ' Convert number into date
End Function

Unfortunately, there is no mention on how to encode dates within the RQL manual. There are a number of RQL queries where you can pass in dates as parameters (such as Seach and Extended Search), however these dates must first be converted to a floating point number.

Although undocumented, the encodedate method is available within the RDCMSAsp.RDPageData object.

Function EncodeDate(OldDate)
   Dim objIO As Object ' Define object
   Set objIO = CreateObject("RDCMSAsp.RDPageData") ' Create object
   EncodeDate = objIO.encodedate(OldDate) ' Convert date into a number
End Function
       

Downloads

 

QuickLinks

 

Channel