Hi all.
I have a problem with DateUtils.AddPeriod and DST which is In the USA today March, 13 2022
Here is my code
I attached a small project so you can try yourself.
My question is - how to add 1 hour to 03/13/2022 1:00 AM to get 03/13/2022 2:00 AM but not 3:00 AM?
My code creates notes in the database and the note timestamp should be for 1 hour bigger than the previous one. So if the previous one was 03/13/2022 01:00 AM the next one should be 03/13/2022 02:00 AM and so on.
On DST day I have this problem.
On my code in lines 24,25 my code adds 1 hour to the previous timestamp (you can see it in the textbox if you run my project) but returns 03/13/2022 3:00 AM but not 2:00 AM.
Thanks.
I have a problem with DateUtils.AddPeriod and DST which is In the USA today March, 13 2022
Here is my code
Add 1 hour:
Private Sub GetStrTo(strFrom As String) As String
Try
Dim TimeFormatShow As String="hh:mm a",DateFormat As String="MM/dd/yyyy"
DateTime.TimeFormat=TimeFormatShow
DateTime.DateFormat=DateFormat
Dim Arr() As String
Dim NotTimeDate As String,NoteTimeStr As String
Dim P As Period
Dim Tick As Long ,NewTick As Long
Dim strTo As String
Dim AddHour As Int
Arr=Regex.Split(" ", strFrom)
NotTimeDate=Arr(0)
NoteTimeStr=Arr(1) & " " & Arr(2)
Tick=DateTime.DateTimeParse(NotTimeDate,NoteTimeStr)
AddHour=1
P.Hours=AddHour
NewTick=DateUtils.AddPeriod(Tick,P)
strTo=DateUtils.TicksToString(NewTick)
Return strTo
Catch
Log("GetStrTo " & LastException.Message)
Return "Error"
End Try
End Sub
I attached a small project so you can try yourself.
My question is - how to add 1 hour to 03/13/2022 1:00 AM to get 03/13/2022 2:00 AM but not 3:00 AM?
My code creates notes in the database and the note timestamp should be for 1 hour bigger than the previous one. So if the previous one was 03/13/2022 01:00 AM the next one should be 03/13/2022 02:00 AM and so on.
On DST day I have this problem.
On my code in lines 24,25 my code adds 1 hour to the previous timestamp (you can see it in the textbox if you run my project) but returns 03/13/2022 3:00 AM but not 2:00 AM.
Thanks.