Converting generic variable to date

Hi everyone,

I am having a problem in converting string value taken from a DATE TextBox (Get Text). I created the variable as a generic variable - the value it gets is in this format - “dd\mm\yyyy”. couldn’t create the variable as DateTime variable.
I need to convert it into “DateTime” format in order to check whether this date (dd-mm-yyyy) is more then 30 days away from today.

I tried doing several things but it wasn’t successful -
Assign dateVar=DateTime.FromOADate(timeValue)
datevar.ToString(“HH:mm:ss”)

thanks,

1 Like

Hi @shachar
If the datetime format you are getting from get text is in this format dd\MM\yyyy assigned to timeValue variable of type generic
use like this buddy
dateVar = Datetime.ParseExact(timeValue.ToString,“dd\MM\yyyy”,System.Globalization.CultureInfo.InvariantCulture)

or if that get text value is in this format dd-MM-yyyy assigned to timeValue variable of type generic
use like this
dateVar = Datetime.ParseExact(timeValue.ToString,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture)

now you have a datetime variable dateVar
and to find whether it is more than 30 days away from now
use a if condition like this
dateVar>now.AddDays(30)

Cheers @shachar

were you able to convert now @shachar

Thanks!

couldn’t do it. what am i doing wrong??:thinking:

image

1 Like

may i know what is the value of TimeValue variable and what is the datatype of it
Cheers @shachar

actually timevalue is keyword that gives us value of timespan…
are we trying to convert a timespan to date…
or kindly change the variable name from timeValue to different name and try buddy
Cheers @shachar

image

timeValue - image
datatype - GenericValue

dateVar - DateTime variable

1 Like

lets do one thing @shachar
lets check how the value of timevalue is getting displayed with writeline activity to check the format once.
after the get text pass that value to writeline activity and share the screenshot of that output panel with timevalue been displayed
and we need to mention like this buddy
dateVar = Datetime.ParseExact(timeValue.ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)
where as you have like, with backslash and value is in front slash image
image

Cheers @shachar

were you able to convert them now @shachar

yessss!!!:boom: thanks so much, again! you’re a master

1 Like

No Worries
Cheers @shachar

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