Generating filename using date

ssh

Registered User.
Local time
Today, 22:57
Joined
May 22, 2002
Messages
49
How to generate a filename that uses date values? For example, date value is November 21, 1999 and filename should be 21-11-99. Problem was how to separate date parts. Thanks
 
Won't you get files with the same filename if there are more than one for a certain date?

Col
:cool:
 
Dim strFileName As String

strFileName = Day(txtDate) & "-" & Month(txtDate) & "-" & Year(txtDate)
 
Towards the right way but I want 99 instead of 1999.
 
strFileName = Day(txtDate) & "-" & Month(txtDate) & "-" & Right(Year(txtDate),2)


Also, to add a 0 to the front of a month or day that is a single figure you could try this:

PHP:
Dim strFileName As String
    
    If Day(txtDate) < 10 Then
        strFileName = "0" & Day(txtDate) & "-"
    Else
        strFileName = Day(txtDate) & "-"
    End If
    If Month(txtDate) < 10 Then
        strFileName = strFileName & "0" & Month(txtDate) & "-"
    Else
        strFileName = strFileName & Month(txtDate) & "-"
    End If
    strFileName = strFileName & right(Year(txtDate), 2)


I tried to do this line but it didn't work:

strFileName = Format(Day(txtDate),"dd") & "-" & Format(Month(txtDate) ,"mm") & "-" & Format(Year(txtDate),"yy")

When I tried that way the string returned was something like 08-04-1905 which I thought was rather bizarre.
 
Last edited:
I'll give a try, and let you know.
 
Format(YourDate,"mm-dd-yy") worked. Love simple things!
 

Users who are viewing this thread

Back
Top Bottom