Android Question Problem with DateUtils

WebQuest

Active Member
Licensed User
Hi community I'm having problems with dateutils. I am trying to execute a command on a set day, but the command sometimes gets executed and sometimes it doesn't. It appears that the if does not run or does not read the exact day. Any help?
CODE:
Dim day As String
    day=DateUtils.GetDayOfWeekName(DateTime.Now)
    Log("Giorno :"&day)
    Lista_Pizza.Clear
    If day ="Dienstag" Or day ="Martedi" Or day= "Tuesday" Then
    C= s4.ExecQuery("SELECT Nome,PrezzoPizzaTag,Descrizione FROM MenuPizze")
    Else
    C= s4.ExecQuery("SELECT Nome,Prezzo,Descrizione FROM MenuPizze")
    End If
    If C.RowCount>-1 Then
        For i = 0 To C.RowCount - 1
            C.Position = i
            Lista_Pizza.Add(C.GetString("Nome"))
            Lista_Pizza_Desc.Add(C.GetString("Descrizione"))
            If day ="Dienstag" Or day ="Martedi" Or day= "Tuesday" Then
                Lista_Prezzo_Pizza.Add(C.GetDouble("PrezzoPizzaTag"))
                PizzaTag=1
            Else
                Lista_Prezzo_Pizza.Add(C.GetDouble("Prezzo"))
            End If
            
        Next
        C.Close
    End If
 

DonManfred

Expert
Licensed User
Longtime User
Any help?
You are making it difficult to help you.

- Upload a small example which shows the problem.
- Post the LOG you get. It may reveal more info. For ex. What does
B4X:
Log("Giorno :"&day)
print to the log?
 
Upvote 0

WebQuest

Active Member
Licensed User
What I am trying to achieve is this.
CODE:
    Dim day As String
    day=DateUtils.GetDayOfWeekName(DateTime.Now)
    
    If day="Tuesday" Then
        'function...
    End If
 
Upvote 0

WebQuest

Active Member
Licensed User
Hi Erel I tried with int but it returns an error where dateutils looks for a given string

java.lang.NumberFormatException: For input string: "giovedì"
code:
Public Sub GetDayOfWeekName(Ticks As Long) As String
    Dim df As String = DateTime.DateFormat
    DateTime.DateFormat = "EEEE"
    Dim res As String = DateTime.Date(Ticks)
    DateTime.DateFormat = df
    Return res
End Sub
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Why don't you do what Erel suggests? Instead of using ...
B4X:
    day=DateUtils.GetDayOfWeekName(DateTime.Now)
    If day ="Dienstag" Or day ="Martedi" Or day= "Tuesday" Then
... write ...
B4X:
    day=DateUtils.GetDayOfWeek(DateTime.Now)
    If day = 3 Then
 
Upvote 0
Top