Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Convert System Date to mmddyyyy format

alik98709228
Level 3
Level 3

Hello,

 

I am trying to convert system date to in this format: mmddyyyy

So for today which is March 25th, 2021, it should show as 03252021

 

I am using the following formula:

 
Month(GetDate())+'/'+Day(GetDate())+'/'+Year(GetDate())
 
It worked but the results are coming up in format "3/245/2021". Is there a way, I can get the 2 digits for the month without having the "/". For instance. for today, the output should be: 0325202
 
Any ideas?
 
Thanks!
1 Accepted Solution
DavidKangni
Correct answer by
Community Advisor
Community Advisor

Hi @alik98709228 

 

Please use this 

Iif(Month(GetDate())>9, ToString(Month(GetDate())), '0'+ToString(Month(GetDate())))+Iif(Day(GetDate())>9, ToString(Day(GetDate())), '0'+ToString(Day(GetDate())))+ToString(Year(GetDate()))

 

Also make sure to post in ACS forum instead of ACC.

 

Thanks,

David

View solution in original post

8 Replies
Deb007
Level 5
Level 5

Hi @alik98709228 ,

Hope this will work.

 

var a = formatDate(new Date(), "%2M%2D%4Y");
logInfo(a);

 

You can refer to the following for more details.

https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/f-formatDate.html?hl=...

 

Thanks,

Deb

DavidKangni
Correct answer by
Community Advisor
Community Advisor

Hi @alik98709228 

 

Please use this 

Iif(Month(GetDate())>9, ToString(Month(GetDate())), '0'+ToString(Month(GetDate())))+Iif(Day(GetDate())>9, ToString(Day(GetDate())), '0'+ToString(Day(GetDate())))+ToString(Year(GetDate()))

 

Also make sure to post in ACS forum instead of ACC.

 

Thanks,

David

View solution in original post

ramon_bisswanger
Employee
Employee

Or you can simplify the formula slightly:

 

Right('0'+ToString(Month(GetDate())), 2) + Right('0'+ToString(Day(GetDate())),2) + ToString(Year(GetDate()))

Jeens
Level 1
Level 1
Am trying to pass an expiration date through enrichment by concatenating by taking 2variable[variable1||variable2], but after that I am getting the date for
Jeens
Level 1
Level 1
Am trying to pass an expiration date through enrichment by concatenating by taking 2variable[variable1||variable2], but after that I am getting the date format as yyyy-mm-dd, could some one please help me to get the date format as variable_field=ddmmyyyy,
icoggin
Level 2
Level 2

Thanks David. That works for GetDate() but what happens if you apply the formula to a field in which the date is only present some of the time? When the date is not present the value output into the field is "00". Is there anyway to overcome this. I have tried various functions, e.g.IsEmptyString(datefield) - with and without ToString(datefield) - Iif(datefield IS NULL, Iif(Length (datefield) = 0 , etc. etc,. and nothing gets parsed.