Announcement

Collapse
No announcement yet.

Getting System Date and Passing to Function as Long

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

  • Getting System Date and Passing to Function as Long

    This question is a little embarrassing since I have been writing
    code for years but here goes. I am using a function that requires
    the date to be passed in MMDDYYYY format Long integer. The
    the function converts the long integer to a julian date. My problem
    is this.

    Code:
    TDate=Date$
    Replace "-" with "" in TDate
    Date=Val(TDate)
    The problem is 08092001 is returned as yes... 8092001 and I'm
    missing the 0 infront of the eight. I have searched and searched
    but can't find what should be a simple solution. I know that the
    VAL is the problem but does anyone know how I can keep the leading
    zero?

    Red Faced in PA


    ------------------
    There is a principle which is a bar against all information, which is proof against all arguments and which cannot fail to keep a man in everlasting ignorance - that principle is contempt prior to investigation.

    Herbert Spencer

  • #2
    Have not tested the formatting here, otherwise this function works in one of my apps

    Code:
    Msgbox "The date is:" & GetPCDate
    
    '-----------------------------------------------------------------------------------
    Function GetPCDate() Export As String
    Local sTime        As SYSTEMTIME
    Local tDay              As Asciiz * 64
    Local LocalDateFormat  As Asciiz * 64
    GetLocalTime sTime
    LocalDateFormat = "MMddyyyy"
    GetDateFormat 0,0,sTime,LocalDateFormat, tDay, 64
    Function = tDay
    End Function
    ------------------
    Scott

    [This message has been edited by Scott Turchin (edited August 09, 2001).]
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    Comment


    • #3
      I just tested it, the leading zero is there.




      ------------------
      Scott
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        A LONG is never going to have a leading zero. Perhaps you want a different
        variable type there?



        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment

        Working...
        X