I only need part of the variable

Hi,

I only need part of the variable that i am storing, e.g. when using type into i only need the the date and not the date and time

image

storing the values is not a problem but when typing it into a spreadsheet its writing the whole variable.

can somebody help me?

hi @nick.v,

Lets Say strDateVariable has Value β€œ05/04/2020 15:32:02”

Below Expression will return : β€œ05/04/2020”

Convert.ToDateTime(strDateVariable).ToShortDateString

–
Mukesh

2 Likes

@nick.v Another Solution would be to use Split method :

Split(strDateVariable)(0).ToString

2 Likes

@mukeshkala Hi, it won’t be todays date all the time, its the date on the webpage i need to enter into a spreadsheet. Where the date is taken the time is taken aswell so i just want to removed the time from the variable

@supermanPunch @mukeshkala dont worry guys ive fixed it using this SubString(0,1) after the variable

2 Likes

Please use the below - Here we are teling to split by space and get the Value at the 0 index ie Date

strDateVariable.Split(" "c)(0).ToString

–
Mukesh

2 Likes