Results 1 to 5 of 5

Thread: date

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2007
    Posts
    694

    date

    The following code returns the filedate as:
    i.e.
    "152009"
    "1062009"
    ...

    How can I alter the code to show "152009" as "01052009" notice the 0

    Dim fileCreateDate As Date = File.GetCreationTime(strSourcePath)

    Dim strImportDate As String = fileCreateDate.Day.ToString() & "" & fileCreateDate.Month.ToString() & "" & fileCreateDate.Year.ToString()

    Thanks

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: date

    The ToString accepts a format string as a parameter...

    Code:
    Dim strImportDate As String = fileCreateDate.Day.ToString("00") & "" & fileCreateDate.Month.ToString("00") & "" & fileCreateDate.Year.ToString("0000")
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: date

    You don't need to split the date up like that just to format it though. You can do it in 1 ToString call.

    Code:
            Dim fileCreateDate As Date = File.GetCreationTime(strSourcePath)
            Dim strImportDate As String = fileCreateDate.ToString("ddMMyyyy")

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2007
    Posts
    694

    Re: date

    Thank you

  5. #5
    Frenzied Member Campion's Avatar
    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: date

    To make searching easier, doing yyyyMMdd is a lot easier to read.
    From my burrow, 2 feet under.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width