SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


DateAdd() - how to add 5 hours and 25 minutes to a date?


DateAdd() - how to add 5 hours and 25 minutes to a date?

Author
Message
Jens Gerbitz
Jens Gerbitz
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 11
Hi there,

This is actually a question re how to do this in SSRS's Report Designer 1.0, please forgive me if this isn't the right site, but I'm close to losing the plot on this.

Basically, I have a date to which I need to add a time span consisting of multiple (what MS calls) dateparts. All of the sites / forums I've come across deal only with the syntax of one datepart, i.e. adding days OR hours OR minutes, etc.

I need to add hours AND minutes using DateAdd()... Appreciate any help!

Many thanks,
Jens
batgirl
batgirl
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1707 Visits: 1820
try something like this:

DATEADD(HOUR,5,DATEADD(MINUTE,25,"origdatetime"))
Jens Gerbitz
Jens Gerbitz
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 11
You did it, Batgirl! Thanks, I seriously owe you a beer, my weekend is now officially made.
Cheers,
Jens
batgirl
batgirl
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1707 Visits: 1820
Glad it worked - I will enjoy that beer!
Michael Valentine Jones
Michael Valentine Jones
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5790 Visits: 11771
This also works:

select
Curr_Datetime= getdate(),
[Curr_Datetime Plus 05:25] =getdate()+'05:25:00.000'



Results:
Curr_Datetime           Curr_Datetime Plus 05:25
----------------------- ------------------------
2013-08-09 14:52:58.457 2013-08-09 20:17:58.457

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search