cancel
Showing results for 
Search instead for 
Did you mean: 

XMII 12.2 expression

0 Kudos

Hi,

I have this expression where I change a date format for my condition. But I can not test for dates I get Convertion error. here is my condition:

stringif(dateformat(datenow,"yyyy-MM-dd'T'hh:mm:ss","MMM_yyyy")=="Aug_2013", "true", "false") - it returns true but that is not how i need my condition.

I need to check if date is History, Present or Future date. I get conversion exception error when I use any date method e.g:

datecompare(dateformat(datenow,"yyyy-MM-dd'T'hh:mm:ss","MMM_yyyy")=="Aug_2013", "true", "false").

Any suggestions on how I can convert string "Aug_2013" to a date data type?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Bheki:

1. convert the date you want to compare to xml date format:
datetoxmlformat(dateString, fromFormat)

2. then use the converted date with datenow:
datecompare(datenow, date2)

3. put all that together
datecompare(datenow,datetoxmlformat(dateString, fromFormat))

if you want to use first day of the month or last day of the month you can use the following functions:

monthend(date)

monthstart(date)

hope it helps,
Arnaud

Answers (2)

Answers (2)

0 Kudos

Hi

Thanks Arnaud and Anuj for you input. It all worked well especially with the inclusion of monthstart function. It helped me where I wanted to test current date excluding time in hours and minutes.

You guys are grooming me as I am still young in XMII.

Thanks,

Bhekk

Former Member
0 Kudos

Hi Bheki,

In addition to what Arnaud said, all the date functions (datecompare,datediff etc) will work only with the dates in XML format i.e yyyy-MM-ddTHH:mm:ss. Please make sure you have converted the various date strings you want to play around with, in XML format using 'datetoxmlformat' function.

Best Regards,

Anuj