# Check min and set according to it

Hi,

I want to check minutes in time if min < 30 set time as 00:00:00,else set time as 00:30:00

Thanks,

Hi,

If min<30

``````dateTimeVar = New DateTime(dateTimeVar.Year,dateTimeVar.Month,dateTimeVar.Day,dateTimeVar.Hour,0,0)
``````

if min>=30

``````dateTimeVar = New DateTime(dateTimeVar.Year,dateTimeVar.Month,dateTimeVar.Day,dateTimeVar.Hour,30,0)
``````

Does this work for you?

Regards,

I have one question.
If current time is 11/20/2021 14:06:36 , now min < 30 , then I want FromTime = 11/20/2021 13:30:00 and ToTime = 11/20/2021 14:00:00

and If current time is 11/20/2021 14:36:36 , now min > 30 , then I want FromTime = 11/20/2021 14:00:00 and ToTime = 11/20/2021 14:30:00

Hi,

Can you try the following?

If min <30

``````dateTimeFrom = New DateTime(dateTimeVar.Year,dateTimeVar.Month,dateTimeVar.Day,dateTimeVar.Hour,30,0).addHours(-1)

dateTimeTo =New DateTime(dateTimeVar.Year,dateTimeVar.Month,dateTimeVar.Day,dateTimeVar.Hour,0,0)
``````

If min>=30

``````dateTimeFrom = New DateTime(dateTimeVar.Year,dateTimeVar.Month,dateTimeVar.Day,dateTimeVar.Hour,0,0)

dateTimeTo = New DateTime(dateTimeVar.Year,dateTimeVar.Month,dateTimeVar.Day,dateTimeVar.Hour,30,0)
``````

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.