Can you remove "/" from DateTime without converting it to a string?

Hi team,

I have an API I’m calling and the inputs need to be in a Datetime format. However the API wont work with the brackets and the input needs to be like this “2021-06-11T10:30:00”

I have tried to convert it using .ToString and .replace ("/","-") but that wont work as it needs to be a DateTime?

Any ideas?

whats is the excact input data (datatype, value) which you want to convert into a different format?

Hi @Sam93,

You can write the variable back to a DateTime after manupulating it. I assume the variable is a DateTime so try this in an assign:

YourDateTimeVar = CDate(YourDateTimeVar.ToString.Replace("/","-")

Thanks for responding :slight_smile: . I just need to keep this format “2021-06-11T10:30:00”.

input = cdate(“2021-06-11T10:30:00”)
Writeline: 06/11/2021 10:30:00

The cdate has removed the “-” whihc is needed for the API?

Thanks for responding!

As mentioned above. This still returns as “06/11/2021 10:30:00” I have also tried Pare.Exact and it does the same thing.

DateTimeVar=cdate(“2021-06-11T10:30:00”.ToString.Replace("/","-"))
Writeline: 06/11/2021 10:30:00


first is returning a dateTime
second returns a reformatted String

1 Like

No, you can’t. Datetimes don’t have a format. They’re datetimes. It’s like how integers don’t have a format, they’re just integers. When you want to display, type, etc a datetime you convert it to a string (just like an integer).

That’s pointless. Datetimes aren’t stored in a format. They’re probably stored as milliseconds since 1970, or something like that. You format a datetime as you’re outputting it as a string.

How are you calling the API?

Thanks @postwick thought that would be the case. I initially tried the Soap Request but had no luck. So have created it as a new service/new library. The first part of this process gets a token which is working fine but getting it to accepted the date is proving to be tricky.

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