Crystal Reports - Add one hour to a time

Posted on 2009-12-21
Last Modified: 2013-11-15

I have a field in my database where the user writes a time. The field is a string.

Suppose the field contains the string 17:30 - which represents a time of 17:30.

I want a formula to display 16:30 - 18:30 (ie. subtract one hour from the start, and add one hour to te end)

How can I do this?
Question by:MDWinter
    1 Comment
    LVL 100

    Accepted Solution

    Try this formula

    Local TimeVar myTime;
    Local TimeVar startTime;
    Local TimeVar endTime;

    myTime := Time({YourTimeField});

    startTime := Time(DateAdd('h',-1,DateTime(CurrentDate,myTime )));
    endTime := Time(DateAdd('h',1,DateTime(CurrentDate,myTime )));

    CStr(startTime,'HH:mm') & ' - ' & CStr(endTime,'HH:mm')


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now