Problem with datatype while updating the database


#1

Hello,

I’m trying to retrieve date from mail using outlook and compare the same with the system date and their datatype is DateTime. I’m using an if condition to compare the dates and if it’s true, I’m writing the system’s date into a date column of the type DateTime in a database.

The problem is that, the “execute query” activity accepts only strings and if I’m trying to convert into a string using .ToString, it’s considering it as a string in the database and performing subtraction because of the hyphen(-) .

Please suggest a solution.

Thanks,
Tamshi


#2

can you try this in execute query?

sysDateTime.ToString(“yyyy-MM-dd HH:mm:ss.fff”)


#3

Thank you @vvaidya for the reply. I tried this but it is giving me error in SQL syntax.


#4

Can you post your query and error


#5

The error is displayed above.

“insert into checkdate1 (date) values ( “+var2.ToString(“yyyy-MM-dd HH:mm:ss.fff”)+”);”

This is the query where var2 is a dateTime variable that contains the system date and time.

Regards,
Tamshi


#6

“insert into checkdate1 (date) values ( “+timToday.ToString(“M/d/yyyy”)+”);”

If I omit the time and consider only the date, the values in the database aren’t as expected.


#7

I tried with this query “insert into checkdate (date) values (curdate());” where checkdate is the name of the table in the database , date is the name of the column in which values have to be inserted and curdate() is the inbuilt function in MySQL which returns the current date. I worked and I am able to update the date in the database. . :slight_smile: