Forum Discussion

DCat1223's avatar
DCat1223
Frequent Contributor
10 years ago

Custom Date expression / format help

Good afternoon.  I need to create a custom date expression that basically inputs the birthdate of somebody who is 10 years old.  So this expression needs to take today's date and subtract 10 years, f...
  • HKosova's avatar
    10 years ago

    Hi DCat1223,

     

    You can use the aqDateTime and aqConvert objects to build the needed expression.

     

    aqDateTime.Today() returns today's date.
    aqDateTime.AddMonths(date, -120) subtracts 10 years (120 months) from a date.
    aqConvert.DateTimeToFormatStr(date, "%m/%d/%Y") formats a date as "mm/dd/yyyy".

     

    With all of these combined, your expression would be:

    aqConvert.DateTimeToFormatStr(aqDateTime.AddMonths(aqDateTime.Today(), -120), "%m/%d/%Y")