DJWheezyWeez
Technical User
I've mostly got what I need but I'm having trouble translating a formula from crystal syntax to basic syntax.
The code below gives me a string like 180403 which is a YYMMDD format for the current day and uses if statements to include a 0 when the month or day number is a single digit.
The problem I'm having comes when trying to adapt this to basic syntax, specifically with the if statement (or at least that's where the error comes up). The code below works after I've taken out the if statements but I'm having trouble finding the right syntax for the if.
Is there a better way to go about this or can someone help me with the correct basic syntax?
Thanks.
The code below gives me a string like 180403 which is a YYMMDD format for the current day and uses if statements to include a 0 when the month or day number is a single digit.
Code:
shared stringvar DataToEncode := (right(replace(replace(cstr(year(today)),".00",""),",",""),2)) & (if len(replace(cstr(month(today)),".00","")) = 1 then "0" & replace(cstr(month(today)),".00","") else replace(cstr(month(today)),".00","")) & (if len(replace(cstr(day(today)),".00","")) = 1 then "0" & replace(cstr(day(today)),".00","") else replace(cstr(day(today)),".00",""));
The problem I'm having comes when trying to adapt this to basic syntax, specifically with the if statement (or at least that's where the error comes up). The code below works after I've taken out the if statements but I'm having trouble finding the right syntax for the if.
Code:
Dim DataToEncode as String
DataToEncode = (right(replace(replace(cstr(year(today)),".00",""),",",""),2))
Is there a better way to go about this or can someone help me with the correct basic syntax?
Thanks.