Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4554848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:08:33+00:00 2026-05-21T17:08:33+00:00

I am trying to create a formula for a cost column which calculates the

  • 0

I am trying to create a formula for a cost column which calculates the cost based on the difference between other columns and it is not working.

Parking_Cost is the field to have the cost based on the difference between ParkingStartTime and ParkingEndTime * 5 since 1 hours = $5.00.

Formula:

(CONVERT([int],[ParkingEndTime]-[ParkingStartTime]*5,(0)))

I would really appreciate any suggestion?

Regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:08:34+00:00Added an answer on May 21, 2026 at 5:08 pm

    Use DATEDIFF to determine the difference between dates/times. Your formula could be something like this:

    DATEDIFF(minute, ParkingStartTime, ParkingEndTime) / 60 * 5
    

    Of course you could use just

    DATEDIFF(hour, ParkingStartTime, ParkingEndTime) * 5
    

    which is simpler, but it might give you undesired results in some cases. For example, if the start time was 8:55 and the end time 9:05, DATEDIFF(hour, ...) would return 1 although the actual difference is much less, just 10 minutes. It’s because DATEDIFF in essence truncates the times to the units specified and then calculates the difference.

    So a similar situation can be with minutes, but at least with minutes you would have better granularity. For example, you would receive the answer of 60 when calculating DATEDIFF(minute, '5:20:57', '6:20:04'), even though it’s in fact slightly more than 59 minutes, but the inaccuracy is not so big as can be with DATEDIFF(hour, ...).

    If you want to have even better granularity, calculate the difference in seconds and divide by 3600 to get whole hours:

    DATEDIFF(second, ParkingStartTime, ParkingEndTime) / 3600 * 5
    

    UPDATE

    In SQL Server, when an integer is divided by an integer, the result will be integer too.

    If you need the result to be more precise, you can ensure it like this (using the last expression above):

    DATEDIFF(second, ParkingStartTime, ParkingEndTime) / 3600.0 * 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a formula for calculating the percentage difference between two
The first three columns exist. I am trying to create a formula for the
I'm trying to create a Crystal Reports formula field (to calculate the percentage change
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am basically trying to create a display object transformation manager which will allow
I am trying to create an application that will calculate the cost of exotic
I'm trying to create a formula that will have the effect of automatically adding
I'm trying to implement a discrete fourier transform, but it's not working. I'm probably
I am trying to optimize a small program which calculates perfect numbers from a
I am trying to create a report in crystal reports 11 based on this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.