Results 1 to 8 of 8
  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Concatanate a string (VBS)

    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?
    Jerry

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Concatanate a string (VBS)

    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
    Jerry

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Concatanate a string (VBS)

    Jezza,

    I created a vbs file with just the lines
    <code>Outputfile="c:HeartbeatStatus" & Date & ".log"
    msgbox Outputfile</code>
    and it ran fine, but I don't think this is a valid file name.

    StuartR
    Attached Images Attached Images

  4. #4
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Concatanate a string (VBS)

    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 <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Jerry

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Concatanate a string (VBS)

    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.
    Legare Coleman

  6. #6
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Concatanate a string (VBS)

    Thanks Legare

    Things have moved on apace since this post <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    I have implemented it in HTML with a 30 second refresh <img src=/S/sneaky.gif border=0 alt=sneaky width=15 height=15>

    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
    Jerry

  7. #7
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Concatanate a string (VBS)

    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.
    Regards
    Don

  8. #8
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Concatanate a string (VBS)

    Good Point, thank you Don, I shall put that on my "useful list" <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Jerry

Posting Permissions

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