Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Number of digit of day and month

$
0
0
Hello, Is there other possibility to represent number of day in forrmat xx, eg if day is 1 i would like to see 01, and the same with month, as you can see bellow i am checking Len(MyMonth) to add 0 if month has 1 number. I tried to use:
DatePart("mm", dt) but its not working.

 
Dim dt As Date = Now
            Dim MyYear As String = DatePart("yyyy", dt)
            Dim MyMonth As String = DatePart("m", dt)
            Dim MyDay As String = DatePart("d", dt)
            Dim MyFileName As String
            If Len(MyMonth) = 1 Then
                MyFileName = "Report1_" & MyYear & "-" & "0" & MyMonth & "-" & MyDay & ".xls"
            Else
                MyFileName = "Report1_" & MyYear & "-" & MyMonth & "-" & MyDay & ".xls"
            End If

            FName = OutDir & MyFileName


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>