Change date format and keep times

Hi @william.coulson,

use below format
"dd/MM/yyyy hh:mm:ss tt"

Regards,
Arivu

1 Like

@lakshman,

That’s worked, thank you. Do I need to use FinishTime - StartTime to get a total time? FinishTime.Subtract(StartTime) has a validation error.

1 Like

can you send the error screenshort

TotalTimeSpan= **FinishTime.Subtract(StartTime)**

1 Like

@arivu96,

I’ve tried these two options, that work with DateTime. Do I need to try with -?

Make it both the variable are datetime format.
Else convert to date format
Convert.ToDateTime(FinishTime).Subtract(Convert.ToDateTime(StartTime))

Regards,
Arivu

1 Like

@arivu96,

That’s worked, than you very much.

Hey @arivu96,

The solution you’ve given me isn’t working now. Any ideas why? Have tried with FinishTime and StartTime as String and GenericValue and neither worked.

This is the error…

image

1 Like

@Palaniyappan, any ideas? Trying to subtract dates in string form.

1 Like

sure buddy
But may i know where we are gettting the input for date
@william.coulson

@Palaniyappan,

At the moment, I am getting StartDate and Finish Date from DateTime.Now.ToString(“dd/MM/yyyy hh:mm:ss”). I need to get a total time from subtracting these two variables. I am using @arivu96’s solution:

Which is coming up with an error, screenshotted above

1 Like

Great
so the expression be like this for different scenarios
date_start = Datetime.ParseExact(StartDate.ToString,“dd/MM/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)

date_finish = Datetime.ParseExact(StartDate.ToString,“dd/MM/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)

date_start and date_finish is a variable of type System.Datetime

nw
for day difference
int_date = (date_start-date_finish).TotalDays

for minutes difference
int_minutes = (date_start-date_finish).TotalMinutes

for seconds difference
int_seconds = (date_start-date_finish).TotalSeconds

Cheers @william.coulson

4 Likes

@Palaniyappan,

Can I get hours using int_date = (date_start-date_finish).TotalHours?

1 Like

yah of course
int_hours= (date_start-date_finish).TotalHours

Cheers @william.coulson

@Palaniyappan,

I assume the variables are Integers? Silly question

1 Like

as System.Double
Cheers
@william.coulson

1 Like

Were we able to get them now
@william.coulson

@Palaniyappan,

I have set the date format to dd/MM/yyyy and it is still outputting as MM/dd/yyyy. Time is correct though.

StartDate is date_start

In DateTime.ParseExact atlast include .ToString(“dd/MM/yyyy hh:mm:ss”)

Cheers @william.coulson

@Palaniyappan

That’s worked, thank you. I will resolve my Total Time issue by using DateTime in another assign activity.

Thank you all for your help! @arivu96 @lakshman

1 Like

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