473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Minimum Value (Date)

I have 6 date fields in a query record & want to create one field to access smallest date value in each record.

Please help on building expression.
Sep 28 '16 #1
3 2646
PhilOfWalton
1,430 Expert 1GB
Bit short of information.

Are the dates all related to different things like BuyDate, SellDate or are they all referring to the same thing like Stock at a StockDate?

Phil
Sep 29 '16 #2
they are like buy date, sale date, delivery date & are in the same record set. I am getting this into a query & want to create a new field in query itself to get me smallest date out of all these dates.
Sep 29 '16 #3
PhilOfWalton
1,430 Expert 1GB
I have a table consisting of ID and Date1 to Date6

Here is the SQL for the output
Expand|Select|Wrap|Line Numbers
  1. SELECT Dates.*, LowestDate([ID]) AS LowDate
  2. FROM Dates;
  3.  
Here is a bit of code to scan the dates to find the lowest

Expand|Select|Wrap|Line Numbers
  1. Function LowestDate(ID As Long) As Date
  2.  
  3.     Dim MyDb As Database
  4.     Dim DateSet As Recordset
  5.     Dim LowDate As Date
  6.  
  7.     Set MyDb = CurrentDb
  8.     Set DateSet = MyDb.OpenRecordset("SELECT Dates.* FROM Dates WHERE ID = " & ID & ";")
  9.  
  10.     With DateSet
  11.         LowDate = !Date1
  12.         If !Date2 < LowDate Then
  13.             LowDate = !Date2
  14.         End If
  15.         If !Date3 < LowDate Then
  16.             LowDate = !Date3
  17.         End If
  18.         If !Date4 < LowDate Then
  19.             LowDate = !Date4
  20.         End If
  21.  
  22.         If !Date5 < LowDate Then
  23.             LowDate = !Date5
  24.         End If
  25.         If !Date6 < LowDate Then
  26.             LowDate = !Date6
  27.         End If
  28.         .Close
  29.         Set DateSet = Nothing
  30.     End With
  31.  
  32.     LowestDate = LowDate
  33.  
  34. End Function
  35.  
Phil
Sep 29 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Porthos | last post by:
Hi All, I'm trying to find the minimum value of a set of data (see below). I want to compare the lengths of these attribute values and display the lowest one. This would be simple if I could...
3
by: RobG | last post by:
I would like a query that will tell me the minimum non-zero value in a row. Say I have a table with a column called recordID that contains unique record IDs, and have a set of values named V1,...
5
by: Bas Wassink | last post by:
Hi there, I was wondering what the standard (C89) states what the minimum value of FOPEN_MAX should be? K&R just state that FOPEN_MAX is implementation-defined and when googling for an answer I...
1
by: alan_conoco | last post by:
Hello all, I have a table looks like this in Access Product Sale Date A date A date A date B date B ...
1
RobH
by: RobH | last post by:
I have 4 text boxes on a form (A,B,C & D) and I need to have a button (when Clicked) make the 5th box (E) appear with the value from the smallest valued box. Eg A = 2 B = 1 C = 5 D = 7 ...
3
by: saif9171 | last post by:
Hi: Here is my question... Below program needs arguments from command line. How to modify the parent program to provide at least five integers inside of the program, not from command line and keep...
7
by: mingke | last post by:
I tried to find max and min value from arrays. and my code so far looks like this: for (i=0; i<size2; i++){ for (j = 0; j < 4; j++){ by_max=by; if...
5
by: omar999 | last post by:
hi - im trying to return the minimum value from selected columns. however for some non obvious reason it only works when 3digit long numbers are entered in to the columns in question. the below...
1
by: peachdot | last post by:
hi, i used min() to find the minimum value of an array/list. it gives the min value of each row. But how do i know in which column does the min value is..? a=for j in range(4)] a= a= a= a=
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.