Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
aguirre
Creator
Creator

Not clear how Date# works and how to pass variables

Hello,

I have some problems understanding  how to pass dates to Date#.

Could you please explain why this happens ?

 

let daterif = Date(today(),'YYYY-MM-DD');
let ok= Date#(daterif , 'YYYY-MM-DD');
let ko= Date#($(daterif ), 'YYYY-MM-DD'); 

trace $(ok); // this prints 2021-05-14
trace $(ko); // this prints 2002
trace datarif;

Why does "trace $(ko) " prints 2002? 

Why does "trace $(ok)"  prints the date in the correct format (without dollar expansion)?

Thanks.

 

 

 

Labels (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar

Date#($(daterif ), 'YYYY-MM-DD'); <= contains a dollar expansion. So it calculates the expression 2021 minus 5 minus 14 first. The result of that calculation is 2002. The Date# function sees that 2002 does not have the format YYYY-MM-DD so it can't turn it into a date. And that's why it stays 2002.


talk is cheap, supply exceeds demand

View solution in original post

1 Reply
Gysbert_Wassenaar

Date#($(daterif ), 'YYYY-MM-DD'); <= contains a dollar expansion. So it calculates the expression 2021 minus 5 minus 14 first. The result of that calculation is 2002. The Date# function sees that 2002 does not have the format YYYY-MM-DD so it can't turn it into a date. And that's why it stays 2002.


talk is cheap, supply exceeds demand