Solved

increment timestamp by 24 hours

Posted on 2014-10-06
3
101 Views
Last Modified: 2014-10-17
hi experts

I have table USERLOCK
something like
Id        Lockedtime
1      2014-10-06 15:01:25.170

In my sql i need to return Lockedtime as 2014-10-07 15:01:25.170  (2014-10-06 15:01:25.170 + 24 hours )

select ID, Lockedtime+24 from USERLOCK 

Open in new window

doesnt seem to work , it increments by 24 days
any clue how i can increment the time by 24 hours?

thanks
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 40364496
select ID, DATEADD(day, 1, Lockedtime) as Lockedtime from USERLOCK

Datetime values are stored internally as a double, where 1=a single day, so doing a +24 to a datetime would be the equialent of DATEADD(day, 24, Lockedtime).
0
 

Author Comment

by:royjayd
ID: 40364721
thanks
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40365280
Just in case this is for a MySQL Timestamp field*

DATE_ADD(Lockedtime, INTERVAL 24 HOUR)

or

DATE_ADD(Lockedtime, INTERVAL 1 DAY)

----
:) * these might indicate MySQL: "timestamp" that means a date & time and "my sql"
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question