ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

VBScript

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

  • VBScript

    I have the following VBScript
    Code:
    <!-- current date !-->
    <% year = DatePart("yyyy", date)%>
    <% month = DatePart("m", date)%>
    <% day = DatePart("d", date)%>
    <%currentdate =  "1" & Mid(year, 3, 2) &  month & day %>
    which gives me this ==>Today is 106127

    My question is how do I KEEP the "0" before the month and/or Day?

    Thanks
    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: VBScript

    Can you try this ...

    <% month = DatePart("mm", date)%>
    <% day = DatePart("dd", date)%>
    Thanks,
    Giri

    Comment


    • #3
      Re: VBScript

      I did it doesnt like it


      jamie
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: VBScript

        Wht abt something like below .....Not sure of proper syntax .......

        SET @yy = DATEPART(yy, @date)
        SET @mm = CASE WHEN LEN(DATEPART(mm,@date)) = 1 THEN '0' + CAST(DATEPART(mm,@date) AS varchar(2))
        ELSE CAST(DATEPART(mm,@date) AS varchar(2))
        SET @dd = CASE WHEN LEN(DATEPART(dd,@date)) = 1 THEN '0' + CAST(DATEPART(dd,@date) AS varchar(2))
        ELSE CAST(DATEPART(dd,@date) AS varchar(2))
        Thanks,
        Giri

        Comment


        • #5
          Re: VBScript

          This will do it sure its not pretty but it functions
          Code:
          <!-- current date !-->
          <% year = DatePart("yyyy", date)%>
          <% month = DatePart("m", date)%>
          <% day = DatePart("d", date)%>
          <%
          if  month < 10 then
          month = "0" & month
          end if
          if  day  < 10 then
          day = "0" & day
          end if
          %>
          <% currentdate =  "1" & Mid(year, 3, 2) &  month & day %>
          If interested the SQL would look like this then - summing all records (weight) from Iseries table
          from TODAY converted date format to *CYMD

          Code:
          sqlstmt = "SELECT sum(WADLWT)as TotalShippedLBI  FROM lbifil.wkartno WHERE WADAT = "  & currentdate 
                set RS = Connection.Execute(sqlstmt)
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: VBScript

            Not sure about VB but in VBA i use this ...

            Code:
                STRDate = Format(date, "DD/MM/YYYY")
                BackwardsDate = Format(date, "YYYYMMDD")
                SillyUSDate = Format(date, "MM/DD/YYYY")
                MyDay1 = Format(date, "D")
                MyDay2 = Format(date, "DD")
            etc

            Greg
            Greg Craill: "Life's hard - Get a helmet !!"

            Comment

            Working...
            X