Graphics

 View Only
  • 1.  Formatting Date & Time

    Posted 08-07-2023 17:14

    Hello,

    I have a DataLinq source (date) that's coming in as ddd, DD MMM.  I'd like to reformat it so it's the MMMM D, YYYY.  What's the best way to achieve this?  I am assuming using Visual Logic but I didn't have luck with getting it to update after creating the following function block order: DatalLinq > Encode Date Time > Format Date Time > Text 

    How would you advise I achieve this?  



    ------------------------------
    Steve Trauger
    ------------------------------


  • 2.  RE: Formatting Date & Time

    Posted 08-08-2023 04:54

    so its how does the data you are getting look? "Tue 02 Aug"



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 3.  RE: Formatting Date & Time

    Posted 08-08-2023 07:21

    Correct; I'd like to change it so it's August 2, 2023 instead.  



    ------------------------------
    Steve Trauger
    ------------------------------



  • 4.  RE: Formatting Date & Time

    Posted 08-08-2023 09:14

    I'm sure someone has a better way than this but if you put this onSetText on the text object that's tied to the date field it will display how you want.

    dim day, month, year as string

    month = split(text, " ")(2)
    day = split(text, " ")(1)
    year = split(text, " ")(0)


    Select Case month
    Case "Jan"
    month = "January"
    Case "Feb"
    month = "February"
    Case "Mar"
    month = "March"
    Case "Apr"
    month = "April"
    Case "May"
    month = "May"
    Case "Jun"
    month = "June"
    Case "Jul"
    month = "July"
    Case "Aug"
    month = "August"
    Case "Sep"
    month = "September"
    Case "Oct"
    month = "October"
    Case "Nov"
    month = "November"
    Case "Dec"
    month = "December"
    End Select


    text = month & " " & day & "," & year



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 5.  RE: Formatting Date & Time

    Posted 08-08-2023 09:15

    oh my bad that would actually display this;

    August 02,Tue



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 6.  RE: Formatting Date & Time

    Posted 08-08-2023 09:19

    You'll need a source for year, in my case I just made a textbox called "Year" where I wrote the year but you could tie that to VL or to a widget with just YYYY. 

    Then use this script on your text object instead;

    dim day, month, year as string
    dim yrText as xpTextObject

    Scene.GetObjectByName("Year", yrText)

    month = split(text, " ")(2)
    day = split(text, " ")(1)
    year = yrText.Text

    Select Case month
    Case "Jan"
    month = "January"
    Case "Feb"
    month = "February"
    Case "Mar"
    month = "March"
    Case "Apr"
    month = "April"
    Case "May"
    month = "May"
    Case "Jun"
    month = "June"
    Case "Jul"
    month = "July"
    Case "Aug"
    month = "August"
    Case "Sep"
    month = "September"
    Case "Oct"
    month = "October"
    Case "Nov"
    month = "November"
    Case "Dec"
    month = "December"
    End Select


    text = month & " " & day & "," & " " & year



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 7.  RE: Formatting Date & Time

    Posted 08-08-2023 12:41

    Thanks!  That worked; what I did was make a text object where I used a clock to fetch the year in VL and then formatted that to display as YYYY to the text of that object.  I then positioned that aligned left and added the script above to the date source aligned right.  

    I made one adjustment: I added this to the visual basic script to convert the date to drop any leading 0s:

    day = CStr(Val(day))

    Thanks again, Simon!!



    ------------------------------
    Steve Trauger
    ------------------------------