set decimals in expression on dates (1 Viewer)

jedder18

Just Livin the Dream!
Local time
Yesterday, 16:59
Joined
Mar 28, 2012
Messages
135
Using Access 2007
Win 7


Total_Time: Format(nz(DateDiff("n",[Start],[End])/60))

This is my expression in a query.
I need to only show 2 decimal places in the results field.
HELP!
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 19:59
Joined
Jan 23, 2006
Messages
15,379
What do you think your Total_Time will look like?
I don't see what you are doing with Format
 

jedder18

Just Livin the Dream!
Local time
Yesterday, 16:59
Joined
Mar 28, 2012
Messages
135
format the start and end times to number, allowing for blank or null

some answers will be 2.33366666
 

MarkK

bit cruncher
Local time
Yesterday, 16:59
Joined
Mar 17, 2004
Messages
8,179
I think jdraw's point is that the Format() function takes two parameters. You are only passing it one.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 19:59
Joined
Jan 23, 2006
Messages
15,379
Yes Mark that's the question re Format.

I think as long as Start and End are Date data type --and these are very poor choices for names -- that something like this (untested) should work.

Total_Time: Round((DateDiff("n",[Start],[End])/60),2)
 

MarkK

bit cruncher
Local time
Yesterday, 16:59
Joined
Mar 17, 2004
Messages
8,179
Yeah, or if you do use Format() you can do . . .
Code:
Format(12.34567890, "0.00")
. . . but Format(), as far as I know, always returns a string, and if you want to round a number, you usually want a numeric result.
 

jedder18

Just Livin the Dream!
Local time
Yesterday, 16:59
Joined
Mar 28, 2012
Messages
135
JDraw...I agree, the names are terrible. I'm working on an existing db of anothers' creation and too far in to change the names.

I edited this post....I forgot to put the Round function in...
this formula works...

Excellent. Thanks so much.
 

Users who are viewing this thread

Top Bottom