Announcement

Collapse
No announcement yet.

Simple date formatting for Device Last Change

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

  • socalsharky
    replied
    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.

    (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.)
    Did you get the script working? I like the idea of displaying "today" in HST. If you don't mind, I would like to borrow your scripting code.

    Leave a comment:


  • Uncle Michael
    replied
    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.

    Leave a comment:


  • ZeroGravitas
    replied
    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.)

    Leave a comment:


  • Uncle Michael
    replied
    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.

    Leave a comment:


  • ZeroGravitas
    started a topic Simple date formatting for Device Last Change

    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.
Working...
X