Dates

I have a datetime in a mssql database.

When I do

date = system.db.runScalarQuery(‘QueryForDate’)

How do I subtract one minute from date?

I can do date.month += 1, but not date.minute +=1

It appears to be a java Date, but none of the info on the internet seems to work.

Thanks,

Mike

You’ll want to use the SQL Server Function DATEADD() to manipulate the datetime within the query itself:

w3schools.com/sql/func_dateadd.asp

Here’s an example of adding one minute to a datetime value stored in the column “t_stamp”:

date = system.db.runScalarQuery("SELECT DATEADD(minute,1,t_stamp) from test_table where id=1")