Link to home
Start Free TrialLog in
Avatar of Bob Butcher
Bob ButcherFlag for United States of America

asked on

how to subtract 2 from from my datetime value in t-sql

I have a field in my table called capturedate which stores a float value which looks like something like this - 40821.28441

my t-sql code is like this:

declare @mypunchdate datetime;
set @mypunchdate = cast(capturedate as datetime);

this code converts the value to a datetime value fine - now what I need to do is before I pass @mypunchdate to my stored procedure I need to subtract 2 from it - so I need to add more code above so it takes that capturedate subtracts 2 and then I put it in my @mypunchdate variable.

What would the code look like to do this above?

Thanks so much in advance. I am lost when it comes to t-sql.
Avatar of vvk
vvk

since it is logically datetime value, you need to substract 2 of what? minutes, seconds, days, ticks?
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Butcher

ASKER

I need to subtract 2 from days only from that float field.
This code is exactly what I needed. Thank you.