How to Remove timestamp from DateTime Variable

When I am converting a String Date to DateTime variable a timestamp is getting added and I am not sure how to remove that, I only need date. Please help!

The expressions are like this:


The above expression is assigned to strDOS string variable

Here, Counter is a variable containing index.

Everything works fine till here.

Later when I assign string date to a DateTime variable using this:

StrDos - Contains Date in string format
formatconversion - is date format ( yyyy/MM/dd)

So once this is applied time stamp is added. I want to get rid of time stamp. the variable should remain a DateTime as I am using it on Parameter to write it to SQL query.

Looking forward for some help!

Thanks in advance :smiley:


There is no such thing, a DataTime type will always have a “time” part in it, you need to just ignore it.

You can remove time by creating another string variable
strdate=split(DateTimeVariable.tostring," ")(0)

1 Like


Check below for your reference


Hope this may help you


1 Like

Thanks lot @Srini84 and @ghazanfar , but I needed this for filtering rows on SQL,

SQL Query:

UPDATE dbo.TableName
SET Column1=0
WHERE MemberID='xxxx/' AND DateOfService='2021-05-22';

So if Date contains 2021-05-22 00:00:00 it will not match the clause. If anyone else has better solution it will be great. As it is known, to UPDATE data in SQL DB, the Data type passed from Variable should match with that of Column variable type on DB.

Say a column in DB table is of type DateTime , the variable using for Passing the value should alos be DateTime and Not a string.

Hope my question is clear. Thanks again for you all. :smiley:

If anyone else has better solution to this, your help is appreciated.

Hi Rajesh,
I think you don’t need datetime variable in uipath to get data from sql query only date variable of type string will work.

you can pass string value to filter this for example your scenario

your query

UPDATE dbo.TableName
SET Column1=0
WHERE MemberID=‘xxxx/’ AND DateOfService=‘2021-05-22’

consider only this part of query

AND DateOfService=‘2021-05-22’

"AND DateOfService="+"'"+DateStringVariable+"'"

the above code you will use to filter data using execute non query activity in uipath. It will give you expected result.



Check below for your reference

Hope this may help you


1 Like

Use datetimevar.tostring(“dd-MM-yyyy”)

This sounds interesting, Let me check that. Thanks lot

This will convert the Data Type to string right? I want the data type to remain DateTime.

Hi I am using Parameters, and I tried to insert string Date to Query, getting this following error.

Execute Non Query

And the Query and Parameter looks like this:

Hi @Rajesh_Shet ,

Try to pass the date format like MM/dd/yyyy.


1 Like

Hey! @Rajesh_Shet,
you can remove the Timestamp by using the RegEx.

Follow below steps:

  1. use isMatches activity from the activity panel.
  2. Select advanced from RegEx and in the value field type 00:00:00
  3. in the properties panel choose RegExOption: IgnoredCase

pfa below for your reference

I hope this will works for you

Thanks & Regards

1 Like

Thanks all! I could manage to fix the issue with all these ideas shared by you all.

The issue causing was:

  1. The format as said suggested by @arivu96 and @airwaveexporter
  2. I got clarity that even string can be passed as said by @ghazanfar

I did the following:


And then inserted same to Query. the problem was caused because of these ' ' [Apostrophe Sign] on Query. I removed them and it worked fine.

Example: "UPDATE dbo.Input_Table SET NoOfTrials=@NoOfTrials WHERE InsID='@InsuranceID' AND DOS='@DOS';"

1 Like

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