Show current day with a single digit <10

Hello I need to show the current day with a single digit, for when it is less than the 10th of the month, the day I get it like this:
Now.ToString(“dd”)

In this way, it shows me the days less than 10 with two digits, that is, 01,02, …
How could I omit the 0?

Cint(Now.ToString("dd")).ToString

1 Like

@Aguirre,

This below statement will solve your problem,

Now.ToString(“%d”)

@kumar.varun2,

Your statement will remove zeros in date 01 to 10, 20 and 30 as well.

put percent symbol in format of date.

image

but %d is better approach

This solution is perfect, I ask you for a tip, I will use an “IF <10” “Now.ToString (”% d “)” but “Now.ToString (” dd ")

Do you see it as the most efficient for my problem or do you think there is a better option?

@Aguirre,

I would recommend you that, store date in variable and compare it like below statement

todayDate = Now.ToString(“%d”)

IF todayDate < 10 {
// do your work here
}Else{
// do your other work here
}

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.