Results 1 to 13 of 13

Thread: Warning about Now() function / region time date format change

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2017
    Posts
    761

    Exclamation Warning about Now() function / region time date format change

    Hello!

    I am not sure if this is new only to me, but to me it was:

    I noticed that Windows 11 does not show the weekday when I hover over the date in the taskbar.
    In fact it does not do anything when I click the date / time in the taskbar on Windows 11.

    As the weekend is pretty important to me, I googled and found the suggestion to change the "short date" format.

    I did that in the "administrative language options": I added "TTTT" to the short date. That resulted in the taskbar showing the weekday again in the taskbar.

    I am using the following code to update the date time modified in a RC6 sqlite command statement like that:

    Code:
        Dim Cmd As cCommand
        Set Cmd = CnUser.CreateCommand("UPDATE pages SET pagedatetimemodified=?,pagethumbdirty=? WHERE pageguid=? AND pagebookguid=?")
    
        Cmd.SetDate 1, Now
        Cmd.SetBoolean 2, True
        Cmd.SetText 3, g_currentPage.Guid
        Cmd.SetText 4, tBook.Guid
    
        Cmd.Execute
    My change of the short date would cause "Now" to be for example "Monday, 19.02.2024 02:39:93".

    The cCommand would accept that for date and VB6's "date" type would, too.

    I guess it's my own fault, but while being a beginner at SQLite and not having a clear concept about the data types (and I guess also switching between ADO and other formats), I found myself in a situation where "" or NULL was stored in a SQLite column.

    That is why I invented a NoNull function:

    Code:
    Public Function NoNull(ByVal uAny As Variant, Optional ByVal uFillString As String, Optional ByVal uTreatDecimalNullAsNothing As Boolean = False) As String
    On Error GoTo ErrHandler
    
        If Not IsNull(uAny) Then
            NoNull = uAny
        Else
            NoNull = ""
        End If
    
        If VBA.Len(NoNull) = 0 Then
            If VBA.Len(uFillString) > 0 Then
                NoNull = uFillString
            End If
        End If
        
        If uTreatDecimalNullAsNothing Then
            If NoNull = "0" Then
                NoNull = uFillString
            End If
        End If
    
    Exit Function
    ErrHandler:
    Debug.Print Err.Description
    Call CriticalLog("#NoNull: " & Err.Description & ", err.number: " & Err.Number & ", Params: '" & "" & "'")
    On Error GoTo -1
    Debug.Assert False
    End Function
    And this function would not accept the new format.
    This would throw an error:

    Dim d As Date
    d = NoNull(r!PageDateTimeModified, "00:00:00")

    The function will do this:

    Code:
        If Not IsNull(uAny) Then
            NoNull = uAny'Function will say that "Mittwoch, 19.02.2025 02:12:43" is not null and will return this as the result of the function
    "d" however will not accept this as a date and throw "Type Mismatch".

    Perhaps more people will have customers making this change on their Windows 11, so perhaps my report is helpful to somebody.

    It's quite interesting as it's not simple to get rid of the weekday name.

    This function is not able to remove it:

    Code:
    Public Function FormatDateEx(ByVal u As Date) As Date
        Debug.Print u
        Dim d As Date
        d = Format(u, "yyyy-mm-dd HH:nn:ss")
        FormatDateEx = d
    End Function
    Last edited by tmighty2; Feb 19th, 2025 at 06:06 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width