Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
shane_spencer
Specialist
Specialist

Setting a Variable based on another

I've got two variables:

LET vDashDate = Date(Today()-1,);

LET vDashMonthYear =Month('$(vDashDate)') & ' ' & Year('$(vDashDate)');

Unfortunately for vDashMonthYear instead of reading to be =Month('$(vDashDate)') & ' ' & Year('$(vDashDate)') my load script replaces the vDashDate with the actual date not the variable. How can I fix this so vDashMonthYear is dynamic?

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Maybe like this?

LET vDashDate = 'Date(Today()-1,)';

LET vDashMonthYear = '=Month($' & '(vDashDate)) & ' & chr(39) & ' ' & chr(39) & ' & Year($' & '(vDashDate))';

I don't know where you'll be using vDashMonthYear so depending on the context you may have to drop the initial '=' from the right hand part of the second LET statement.

Peter

View solution in original post

7 Replies
sunny_talwar

May be this:

LET vDashDate = Date(Today()-1);

LET vDashMonthYear = '=Month($' & '(vDashDate)) & ' Chr(39) & ' ' & Chr(39) & Year($' & '(vDashDate))';

juleshartley
Specialist
Specialist

Why can't you just write this straight into the variable rather than do it in the script?

Otherwise you'll need to add quotes etc. as per Sunny's reply

saimahasan
Partner - Creator III
Partner - Creator III

You can write it as

LET vDashDate = Date(Today()-1);

LET vDashMonthYear = Month(Date(Today()-1)) & ' ' & Year(Date(Today()-1));

shane_spencer
Specialist
Specialist
Author

That's not working.

shane_spencer
Specialist
Specialist
Author

I have done as a work-around but it's not a good practise.

shane_spencer
Specialist
Specialist
Author

No the second variable must change is I change the first.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Maybe like this?

LET vDashDate = 'Date(Today()-1,)';

LET vDashMonthYear = '=Month($' & '(vDashDate)) & ' & chr(39) & ' ' & chr(39) & ' & Year($' & '(vDashDate))';

I don't know where you'll be using vDashMonthYear so depending on the context you may have to drop the initial '=' from the right hand part of the second LET statement.

Peter