• Concatanate a string (VBS)

    Author
    Topic
    #448268

    I am putting together a SQL Heartbeat checker which outputs a series of pre-defined data to a log file like so

    Outputfile=”c:HeartbeatStatus.log”

    I know this is a really basic question but I want to put in the current date after Status and have tried:

    Outputfile=”c:HeartbeatStatus” & Date & “.log”

    It didn’t work so tried single quotes but cannot get the file to export, can you help on the syntax please?

    Viewing 1 reply thread
    Author
    Replies
    • #1095687

      No Problems I have solved it, I was right I just had to add a new variable called LogDate like so:

      LogDate = Replace(Date,”/”,””)

      Outputfile=”c:HeartbeatStatus” & LogDate & “.log”

      It outpits like so:

      Status02022008.log

      • #1095713

        It would make a lot more sense to me to use:

        LogDate = Replace(Date,”/”,”-“)

        That should make it look like this:

        Status02-02-2008.log

        Which is a lot easier to read and know what it is.

        • #1095715

          Thanks Legare

          Things have moved on apace since this post grin

          I have implemented it in HTML with a 30 second refresh sneaky

          Whilst accepting your point I have naming conventions at work that I have for log files and it is similar to this

          [Filename]YYYYMMDDHHMM.log

          After my last post it was re-written to this:

          LogDate = YEAR(Date()) & MONTH(Date()) & DAY(Date()) & left(Replace(Time,”:”,””),4)

          to give

          Status2008230005.log

          • #1095823

            Hi Jerry
            I would recommend using:
            LogDate = YEAR(Date()) & Format(MONTH(Date()),”00″) & Format(DAY(Date()),”00″) & left(Replace(Time,”:”,””),4)
            to remove ambiguity between 23 Jan and 3 Dec for example.

            • #1095827

              Good Point, thank you Don, I shall put that on my “useful list” grin

    • #1095688

      Jezza,

      I created a vbs file with just the lines
      Outputfile="c:HeartbeatStatus" & Date & ".log"
      msgbox Outputfile

      and it ran fine, but I don’t think this is a valid file name.

      StuartR

      • #1095689

        Thanks Stuart

        I think we cross posted but to I use this line of syntax

        Set ofile = ofso.createTextFile(OutputFile, True)

        Which effectively writes to that location and creates the file in that location grin

    Viewing 1 reply thread
    Reply To: Concatanate a string (VBS)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: