Dim WeekDay As Int
Dim WeekDayLong() As String = Array As String("ErelsDay","Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
WeekDay = DateTime.GetDayOfWeek(DateTime.DateParse("04/28/2019"))
I already understand dateparse
for example a given date stored in a string variable
when you add 3 days the new date is "04/30/2019"
can somebody help me a b4a code that will display the original date and the new date
both date in mm/dd/yyyy format
Dim Date1 As Long 'milliseconds since year dot
Dim Date2 As Long
DateTime.DateFormat = "MM/dd/yyyy" 'is default, but best to be sure
Date1 = DateTime.DateParse("04/27/2019")
Date2 = DateTime.Add(Date1, 0, 0, 3) 'add 3 days
Log("First Date = " & DateTime.Date(Date1))
Log("Second Date = " & DateTime.Date(Date2))
generates this log (but you could just as easily put the strings to a label as to the log):
First Date = 04/27/2019
Second Date = 04/30/2019
edit: removed date-time arithmetic alternative, because it gets messy with daylight savings / summer time adjustments
reverting back to the original weekday question, another way of doing it might be:
Dim SaveDateFormat As String = DateTime.DateFormat
DateTime.DateFormat = "yyyy-MM-dd"
Dim DateOfInterest As Long = DateTime.DateParse("2019-04-27")
DateTime.DateFormat = "EEEE"
Log("as weekday = " & DateTime.Date(DateOfInterest))
DateTime.DateFormat = "EEEE MM/dd/yy"
Log("as weekday and date = " & DateTime.Date(DateOfInterest))
DateTime.DateFormat = "EEE MM/dd/yy"
Log("as short weekday and date = " & DateTime.Date(DateOfInterest))
DateTime.DateFormat = SaveDateFormat 'restore to original format
Log("as original format = " & DateTime.Date(DateOfInterest))
as weekday = Sunday
as weekday and date = Sunday 04/27/19
as short weekday and date = Sun 04/27/19
as original format = 04/27/2019
Although I'm coming at it from a physics-time point of view, but you're right that from a clock-time point of view, I should have added a caveat that things will go a bit awry twice a year when daylight savings/summer time kicks in or out (although curiously, leap days are accounted for but leap seconds are not - what's that about?!?!)
Given that the original question was about whole days and regardless of their length, I've rectified my post above.
I did watch this, and it was great - I hadn't encountered that one-hour-is-three-hours time zone trap before, but as soon as you demonstrated it, I thought: man, I bet you must have explained that a few hundred times, no wonder you didn't hold back on declaring my arithmetic to be a mistake ;-)