We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Can I use the DateAdd function to subtract 12 hours from "CurrentDateTime"?  Please give examples.  Thank you

Vannest01
Vannest01 asked
on
Medium Priority
1,767 Views
Last Modified: 2012-05-06
Can I use the DateAdd function in Crystal Reports 10 to subtract 12 hours from "CurrentDateTime"?  Please give examples.  Thank you
Comment
Watch Question

Yes.

Put the following in a formula -

dateadd("h",-12,CurrentDateTime)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Should this work?
{Event.EDate}={@Date -12 hours}
with DateAdd("h",-12,CurrentDateTime) as the formula above?
Work for what purpose?  You're doing a comparison between two dates with the "{Event.EDate}={@Date -12 hours}" formula.

Is this going to be in a formula (Where it would return a true/false)?

Or is this going to be part of a select statement?

Author

Commented:
Ahhh, I didn't realize I was doing a comparison.  I was trying to make Event.EDate equal to the current date and time minus 12 hours.  What I need to do is:
{Event.EDate} < CurrentDateTime and
{Event.EDate} > DateAdd("h",-12,CurrentDateTime) and....

Correct?
What you have above (if in a record selection formula) would correctly select records with a {Event.EDate} less then the currentdatetime and greater than the currentdatetime minus 12 hours.

You're not actually doing anything to the event.eddate  "you say make it equal to..."  , just want to clarify that.  

Author

Commented:
Yes, that's what I wanted.
Thanks

Author

Commented:
Thanks for your help.  This is my first post and I was happy with the result.  You made me aware of my error in logic.

Thanks
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.