Android Question [SOLVED] Parse Date - Get Month & Day

konradwalsh

Active Member
Licensed User
Longtime User
Hello
I am using code I found here to get last mondays date.

How do I parse or format the date from 08/15/2016 to August
B4X:
 Try
      'if not exists, create first entry
     Dim LastMonday As Long = GetPreviousDay(2)
     LastMonday = DateUtils.SetDateAndTime(DateTime.GetYear(LastMonday),      DateTime.GetMonth(LastMonday), _
      DateTime.GetDayOfMonth(LastMonday), 23, 59, 59)
              Log("LAST MONDAY  MonthName: " & DateUtils.GetMonthName(LastMonday) & (DateTime.DateFormat="MM/d") &  DateTime.Date(LastMonday))
    Catch
        Log(LastException)
    End Try

Sub GetPreviousDay(DayOfWeek As Int) As Long
   Dim day As Int = DateTime.GetDayOfWeek(DateTime.Now)
   If day <> DayOfWeek Then
      day = (day + 7 - DayOfWeek) Mod 7
   End If
   Dim d As Long = DateTime.Add(DateTime.Now, 0, 0, -day)
   Return DateUtils.SetDate(DateTime.GetYear(d), DateTime.GetMonth(d), DateTime.GetDayOfMonth(d))
End Sub
 

konradwalsh

Active Member
Licensed User
Longtime User
SORRY and Thanks for your time but when I pasted the cod I realised this look stupid

B4X:
LAST MONDAY  MonthName: " & DateUtils.GetMonthName(LastMonday) & (DateTime.DateFormat="MM/d") &  DateTime.Date(LastMonday))


this gets me the result I need

B4X:
DateTime.DateFormat="MMM - dd"
        Log("LAST MONDAY  MonthName  : " &   DateTime.Date(LastMonday))



SORRY FOR WASTING YOUR TIME
 
Upvote 0
Top