• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 639
  • Last Modified:

Update Record with a similar funtion to dateadd

I have a field in my sybase database that holds dates in an interger format. So for example todays date would be 13342 in that field.

I already know how to read that field in a regular date format.

select dateadd(dd, reactivate_date, '1Jan1970') from requests .....

So anything in the reactivate_date column gets returned as a proper date.

I would like to know, how would I take a proper date and convert it back to the number so I can update that particular field using the companies date structure.

Thanks.
0
nplib
Asked:
nplib
1 Solution
 
Jan FranekCommented:
You need to use datediff function - it is in fact inverse function to dateadd:

for example - this will update reactivate_date with today's date in integer format:

update requests
set reactivate_date = datediff( dd, '1Jan1970', getdate() )
where ...
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now