cancel
Showing results for 
Search instead for 
Did you mean: 

Code of days back

Former Member
0 Kudos

I have a number column as date, YYYYMMDD

I am calculating going back in days

using

Currentday - 1

But I want to go back 54 weeks for 2 weeks so I want like days -380 to days -360

Which way to code this:?

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Paul,

Use this code in the selection formula:

cdate(Picture(totext({Number Field},'#'), 'xxxx/xx/xx')) IN

DateAdd('ww',-52,cdate(Picture(totext(x,'#'), 'xxxx/xx/xx'))) TO DateAdd('ww',-54,cdate(Picture(totext(x,'#'), 'xxxx/xx/xx')))

If you wish to go back 360 days, you can use:

cdate(Picture(totext({Number Field},'#'), 'xxxx/xx/xx')) IN

DateAdd('d',-360,cdate(Picture(totext(x,'#'), 'xxxx/xx/xx'))) TO DateAdd('d',-380,cdate(Picture(totext(x,'#'), 'xxxx/xx/xx')))


-Abhilash

Former Member
0 Kudos

Abhilash, it gives error on the first totext (x)

about a missing (

cdate(Picture(totext(x,'#'

abhilash_kumar
Active Contributor
0 Kudos

Sorry, I left a stray variable in there. It should be:

cdate(Picture(totext({Number Field},'#'), 'xxxx/xx/xx')) IN

DateAdd('ww',-52,cdate(Picture(totext(Number Field,'#'), 'xxxx/xx/xx'))) TODateAdd('ww',-54,cdate(Picture(totext(Number Field,'#'), 'xxxx/xx/xx')))


-Abhilash

Former Member
0 Kudos

we get that the remaining text does not appear to be part of the formula on this last part:

TODateAdd('ww',-54,cdate(Picture(totext({OECAN1.CACAND},'#'), 'xxxx/xx/xx')))

abhilash_kumar
Active Contributor
0 Kudos

There needs to be a space between TO and DateAdd.

-Abhilash

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Paul,

You can make use of DateAdd() Function like below.

DateAdd("ww",-1,currentdate())

this will substract 1 week from current date. Similarly you can try different options by changing the first parameter of this function here are the literals that are used in it.

yyyy        Year

q             Quarter

m            Month

y             Day of year

d              Day

w            Weekday

ww          Week

h             Hour

n             Minute

s             Second.

Regards

Niraj