Shop OBEX P1 Docs P2 Docs Learn Events
PLX-DAQ date stamp incorrect in excel — Parallax Forums

PLX-DAQ date stamp incorrect in excel

Hi,

I am using PLX-DAQ to log sensor data in excel. I have a problem with the date stamping.

I want to record the date for each stamp as DD/MM/YY (U.K. style). For some reason dates with days of the months from 1-12 appear in the U.S. format mm/dd/yy but days of the month greater than 12 appear in U.K. format dd/mm/yy. My excel is setup for UK dates and regardless of which type is displayed (U.S. or U.K.) excel still indicates that the cells are formatted as U.K.

I am pretty sure it is a VBA problem rather than a problem with the controller itself as all the controller does is tell excel to get the date from the computer but still thought I should post on here as it is the most likely place for someone to have had experience with this issue.

Thanks for any help

Comments

  • Its ok I found a solution. It is a VBA problem. Seems I just had to tell it to use the dd/mm/yy format otherwise it defaults to U.S. unless it sees a date that could not be U.S. See the original and the modification below.

    Original code in PLX-DAQ
    Private Function ReplaceData(strData)
    
    If Timer < TimeLast Then
        If TimeAdd = 0 Then
            TimeAdd = (86400# - TimeStart)
        Else
            TimeAdd = TimeAdd + 86400#
        End If
        TimeStart = 0
    End If
    
    TimeLast = Timer
            strData = Replace(strData, "TIMER", Str(Timer - TimeStart + TimeAdd))
            strData = Replace(strData, "TIME", Time)
            strData = Replace(strData, "DATE", Date)
            ReplaceData = strData
    End Function
    

    Modified code
    Private Function ReplaceData(strData)
    
    If Timer < TimeLast Then
        If TimeAdd = 0 Then
            TimeAdd = (86400# - TimeStart)
        Else
            TimeAdd = TimeAdd + 86400#
        End If
        TimeStart = 0
    End If
    
    TimeLast = Timer
            strData = Replace(strData, "TIMER", Str(Timer - TimeStart + TimeAdd))
            strData = Replace(strData, "TIME", Time)
            ddate = Format(Date, "mm/dd/yy")
            strData = Replace(strData, "DATE", ddate)
            ReplaceData = strData
    End Function
    
Sign In or Register to comment.