Date Month Year

Dear All,
I have a line of code like this to display today's date month year :
dt=SelectedValue(DateTime());
str_Day=DateTimeFormat("%d",dt);
str_Month=DateTimeFormat("%B",dt);
str_Year=DateTimeFormat("%Y",dt);
GfxTextOut(str_Day+" "+str_Month+" "+str_Year,1530,272);

I want to display the date, month, and year from 3 days ago, but I get an error.
GfxTextOut((str_Day+" "+str_Month+" "+str_Year,-3),1530,272);

Please correct this code
Any help would be highly appreciated.
Thanks for help.

When posting the formula, please make sure that you use Code Tags (using </> code button) as explained here: How to use this site.

Using code button

Code tags are required so formulas can be properly displayed and copied without errors.

Also what error are you getting?

It looks like have some braces in wrong place.

Instead of calling DateTimeFormat() 3 times,

do it once,

dt = SelectedValue( DateTime() );
str_date = DateTimeFormat( "%d %B %Y", dt ); // space separated
GfxTextOut( str_date, 1530, 272 );

And if it for 3 days ago in daily timeframe, dont use SelectedValue() but
dt = Ref( DateTime() , -3 );

2 Likes

Hi Dear Thomas & nsm51

Thanks for your help
Very helpful