Announcement

Collapse
No announcement yet.

Simple date formatting for Device Last Change

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple date formatting for Device Last Change

    Hi all:

    I don't know much about scripting at all however have gotten a couple of immediate script commands to work, namely:

    &nhs.setdevicestring(62, NOW.ToString("ddd d MMM h:mm tt"), true)
    &nhs.setdevicestring(62, hs.DeviceLastChangeRef(70),true)

    I would like to format the date that comes from the second script to be just like the first. I've tried a number of different variations and can't get anything to work.

    I'm sure it's a simple answer but I would really appreciate it if someone has a quick and ready answer.....

    Thanks in advance.

  • #2
    You could do it with a two-line vb.net script:
    Code:
         Sub Main(ByVal Params As Object)
            Dim dteLast As Date = hs.DeviceLastChange(70)
            hs.SetDeviceString(62, dteLast.ToString("ddd d MMM h:mm tt"), True)  
         End Sub
    Maybe someone else has an idea for how to reduce it to a one-liner.
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.500

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

    Comment


    • #3
      Woohoo! I can script! (Sort of.)

      Thank you so much Mike, it does exactly what I was looking for.

      I did have to make one change. When I first ran the script, it came back with a weird output date; based on all the reading & googling I had done up till now, I figured pretty quickly that changing "DeviceLastChange" to "DeviceLastChangeRef" was needed, and it worked exactly as expected.

      (In case anyone was wondering, I am working to output last change dates to HSTouch through virtual devices into which I am putting these dates, with the twist that if it is "Today" I have the output as Today (in a separate virtual device). When it rolls over into tomorrow, I needed to go back and get the last change date and output that in the correct date format. In the end I think it makes perfect sense as a two-step process.)

      Comment


      • #4
        Originally posted by ZeroGravitas View Post
        Woohoo! I can script! (Sort of.)

        Thank you so much Mike, it does exactly what I was looking for.

        I did have to make one change. When I first ran the script, it came back with a weird output date; based on all the reading & googling I had done up till now, I figured pretty quickly that changing "DeviceLastChange" to "DeviceLastChangeRef" was needed, and it worked exactly as expected.
        Glad it worked. Sorry for the typo. I even tested it, then still typed it into the post wrong.
        Mike____________________________________________________________ __________________
        HS3 Pro Edition 3.0.0.500

        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

        Comment

        Working...
        X