Posts

Showing posts with the label dateadd

Convert specific BigInt to DateTime in T-SQL

Convert specific BigInt to DateTime in T-SQL I have bigInt: 635307578922100000 which I need to convert to DateTime . 635307578922100000 DateTime I've tried few ways to do this: SELECT DATEADD(S, CONVERT(bigint,635307578922100000) / 1000, CONVERT(DATETIME, '1-1-1970 00:00:00')) and: SELECT DATEADD(ms, 635307578922100000 / 86400000, (635307578922100000 / 86400000) +25567) While I found the codes above work with bigInts like: 1283174502729 , with my bigInt I get the following error: bigInts 1283174502729 Msg 8115 ... Arithmetic overflow error converting expression to data type datetime. Does anyone have any idea how to solve it? What would be your expected result for the given input '635307578922100000' – StackUser Jul 26 '16 at 8:12 It looks like these are ticks. Possible dupli...

how to extend date by specific condition

how to extend date by specific condition query to extend the valid_till date for a month of tenants who have referred more than two times sample data: ref_id referrer_id referrer_bonus_amount referral_valid valid_from valid_till 263 5 2500 1 2015-07-05 2015-09-05 264 3 2500 1 2015-07-05 2015-09-05 265 5 1000 0 2015-12-13 2016-02-13 266 6 2500 0 2016-04-25 2016-06-24 267 10 1000 1 2015-07-01 2015-09-01 268 5 2500 1 2015-05-12 2015-07-12 269 10 2500 0 2015-08-05 2015-10-05 what I want is to increase valid_till date of referrer_id who has referred more than twice. To get who has referred more than 2 times I'm using this code: > select referrer_id > from Referrals group by referrer_id having count(referrer_id)>2 but how to add one month for referrer_id >2 in valid_till column. I believe dateadd is to be used but i couldnt figure out how. 3 Answers ...