A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Writing an expression using fields with different formats



 
 
Thread Tools Display Modes
  #1  
Old January 8th, 2008, 06:44 PM posted to microsoft.public.access.queries
Whitney
external usenet poster
 
Posts: 126
Default Writing an expression using fields with different formats

I need to subtract a field sum from another, but they are in different
formats. How can I convert one of themor get one to recognize the other?
For example:
Total Shift Time (hh:nn:ss)
Wrap Up Time (standard)

Need to do the following expression:
[Total Shift Time]-[Wrap Up Time]

The problem is I'm pulling the data from two different sources, one provdies
it in hh:nn:ss format, and the other provides the data in standard number
format.
  #2  
Old January 8th, 2008, 07:16 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Writing an expression using fields with different formats

Format does not matter. What matters is the datatype of the field it is
stored in. Are they the same or compatible?
A datetime fields can be subtracted from a datetime field no mattter the
format they are displayed in. But if one is datetime and the other is text
you must do some format/calculation/manipulation.

the other provides the data in standard number format.

Numbers may look the same but be stored in different ways - integer, single,
double, currency.
--
KARL DEWEY
Build a little - Test a little


"Whitney" wrote:

I need to subtract a field sum from another, but they are in different
formats. How can I convert one of themor get one to recognize the other?
For example:
Total Shift Time (hh:nn:ss)
Wrap Up Time (standard)

Need to do the following expression:
[Total Shift Time]-[Wrap Up Time]

The problem is I'm pulling the data from two different sources, one provdies
it in hh:nn:ss format, and the other provides the data in standard number
format.

  #3  
Old January 8th, 2008, 07:37 PM posted to microsoft.public.access.queries
Whitney
external usenet poster
 
Posts: 126
Default Writing an expression using fields with different formats

Sorry for the confusion:

Total Shift Time (Date/Time)
Wrap Up Time (Number)

"format/calculation/manipulation" what can you suggest?



"KARL DEWEY" wrote:

Format does not matter. What matters is the datatype of the field it is
stored in. Are they the same or compatible?
A datetime fields can be subtracted from a datetime field no mattter the
format they are displayed in. But if one is datetime and the other is text
you must do some format/calculation/manipulation.

the other provides the data in standard number format.

Numbers may look the same but be stored in different ways - integer, single,
double, currency.
--
KARL DEWEY
Build a little - Test a little


"Whitney" wrote:

I need to subtract a field sum from another, but they are in different
formats. How can I convert one of themor get one to recognize the other?
For example:
Total Shift Time (hh:nn:ss)
Wrap Up Time (standard)

Need to do the following expression:
[Total Shift Time]-[Wrap Up Time]

The problem is I'm pulling the data from two different sources, one provdies
it in hh:nn:ss format, and the other provides the data in standard number
format.

  #4  
Old January 8th, 2008, 08:59 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Writing an expression using fields with different formats

A datetime field store a 'point in time' and not an 'amount of time' as you
are using it.
Try this if you have seconds in [Wrap Up Time] ---
DateDiff("s",0,[Total Shift Time]-Int([Total Shift Time])) - [Wrap Up Time]

Change "s" to "h" if in hours, "n" if in minutes.
--
KARL DEWEY
Build a little - Test a little


"Whitney" wrote:

Sorry for the confusion:

Total Shift Time (Date/Time)
Wrap Up Time (Number)

"format/calculation/manipulation" what can you suggest?



"KARL DEWEY" wrote:

Format does not matter. What matters is the datatype of the field it is
stored in. Are they the same or compatible?
A datetime fields can be subtracted from a datetime field no mattter the
format they are displayed in. But if one is datetime and the other is text
you must do some format/calculation/manipulation.

the other provides the data in standard number format.

Numbers may look the same but be stored in different ways - integer, single,
double, currency.
--
KARL DEWEY
Build a little - Test a little


"Whitney" wrote:

I need to subtract a field sum from another, but they are in different
formats. How can I convert one of themor get one to recognize the other?
For example:
Total Shift Time (hh:nn:ss)
Wrap Up Time (standard)

Need to do the following expression:
[Total Shift Time]-[Wrap Up Time]

The problem is I'm pulling the data from two different sources, one provdies
it in hh:nn:ss format, and the other provides the data in standard number
format.

  #5  
Old January 9th, 2008, 12:52 AM posted to microsoft.public.access.queries
Whitney
external usenet poster
 
Posts: 126
Default Writing an expression using fields with different formats

It doesn't appear to be working.

I guess what I really need to do is convert Wrap Up Time for a Number to
date time data type to mirror the other metrics. I have several others that
I'll use for the full equation and the are all in date/time data type.

Currently I run a create table query for the Wrap Up Time. Then I use that
data to run another query combining the Total Shift Time and Wrap Up Time,
plus other metrics. Is there a way to change the data type in the table that
is created or the second query so that it reflects the correct total hours,
mins, and seconds as the other metrics do?

"KARL DEWEY" wrote:

A datetime field store a 'point in time' and not an 'amount of time' as you
are using it.
Try this if you have seconds in [Wrap Up Time] ---
DateDiff("s",0,[Total Shift Time]-Int([Total Shift Time])) - [Wrap Up Time]

Change "s" to "h" if in hours, "n" if in minutes.
--
KARL DEWEY
Build a little - Test a little


"Whitney" wrote:

Sorry for the confusion:

Total Shift Time (Date/Time)
Wrap Up Time (Number)

"format/calculation/manipulation" what can you suggest?



"KARL DEWEY" wrote:

Format does not matter. What matters is the datatype of the field it is
stored in. Are they the same or compatible?
A datetime fields can be subtracted from a datetime field no mattter the
format they are displayed in. But if one is datetime and the other is text
you must do some format/calculation/manipulation.

the other provides the data in standard number format.
Numbers may look the same but be stored in different ways - integer, single,
double, currency.
--
KARL DEWEY
Build a little - Test a little


"Whitney" wrote:

I need to subtract a field sum from another, but they are in different
formats. How can I convert one of themor get one to recognize the other?
For example:
Total Shift Time (hh:nn:ss)
Wrap Up Time (standard)

Need to do the following expression:
[Total Shift Time]-[Wrap Up Time]

The problem is I'm pulling the data from two different sources, one provdies
it in hh:nn:ss format, and the other provides the data in standard number
format.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.