| 
										 You are looking for what I would refer to as a "set intersection". The founder of IDL, David Stern, once made a very efficient library of three functions useful for set math. I am too lazy to edit right now, so I paste the fully 'idldoc'umented code at the bottom of this Email.
Provided that your time values are integers, i,e. whole Julian days, not Julian doubles that contain hour/minute/second information, I think you could run the following with David Stern's library:
    dat1days = long( dat1[dat1TimeColumnNo, *] )
    dat2days = long( dat2[dat2TimeColumnNo, *] )
    ; Unfortunately, the below does not return subscripts. Rather, it returns
    ; a non-redundant set of dates that are shared by both 'dat1' and 'dat2'
    sharedDates = SetIntersection(dat1days, dat2days)
    ; The below code assumes that there is no two rows in a single
    ; data set share the same date. The below would have to be modified
    ; if that were not true.
    nSharedDates = n_elements(sharedDates)
    relevantSubscripts1 = lonarr(nSharedDates)
    relevantSubscripts2 = lonarr(nSharedDates)
    ; There is for sure a way using HISTOGRAM to avoid this
    ; FOR loop, but I wouldn't bother to work that out, if the
    ; below WHERE loop is not too time-consuming.
    for i = 0, nSharedDates-1 do begin
        relevantSubscripts1[i] = where(dat1days eq sharedDates[i])
        relevantSubscripts2[i] = where(dat2days eq sharedDates[i])
    endfor
    relevantData1 = dat1[*, relevantSubscripts1] 
    relevantData2 = dat2[*, relevantSubscripts2]OK, here, then, is the Dave Stern library with a demonstration function at the very end. Hopefully, you can copy and paste that into the IDL Workbench (or a text editor) and save it as 'set_math_operator_lib.pro':
;+
; 
; Provides the set union of two positive integer vectors. Duplicates
; are removed from this union.
;
; @File_Comments
;   Functions from RSI (now ITT VIS) founder David Stern that perform the
;   "set operations" UNION, INTERSECTION and DIFFERENCE on positive integer
;   input arguments. These use IDL's HISTOGRAM function for maximum
;   speed and efficiency, if the data range is not overly wide. The
;   specific procedure SET_MATH_OPERATOR_LIBRARY is simply a procedure
;   that demonstrates the three set operator functions contained here.
;   *** WARNING *** These functions will not be efficient on sparse sets
;   with wide ranges, as they trade memory for efficiency.  The HISTOGRAM
;   function is used, which creates arrays of size equal to the range of
;   the resulting set.
;
; @Param
;   intVectorA {in} {required} {type=vector of positive integers} 
;     A set of positive integers
;
; @Param
;   intVectorB {in} {required} {type=vector of positive integers} 
;     A set of positive integers
;
; @Author
;   IDL Founder David Stern
;
; @Examples
;   Run IDL> SET_MATH_OPERATOR_LIBRARY to demonstrate
;
; @History
;   Created August 29, 1997
;
; @Returns
;   A positive integer array of same datatype as highest-precedent input arg
;-
FUNCTION SetUnion, intVectorA, intVectorB
if intVectorA[0] lt 0 then return, intVectorB    ;A union NULL = A
if intVectorB[0] lt 0 then return, intVectorA    ;B union NULL = B
; Return combined set
return, where(histogram([intVectorA,intVectorB], OMIN = omin)) + omin
end
;+
; 
; Provides the set intersection of two positive integer vectors
;
; @Param
;   intVectorA {in} {required} {type=vector of positive integers} 
;     A set of positive integers
;
; @Param
;   intVectorB {in} {required} {type=vector of positive integers} 
;     A set of positive integers
;
; @Author
;   IDL Founder David Stern
;
; @Examples
;   Run IDL> SET_MATH_OPERATOR_LIBRARY to demonstrate
;
; @History
;   Created August 29, 1997
;
; @Returns
;   A positive integer array of same datatype as highest-precedent input arg
;   *** OR *** scalar -1 if the intersection is empty (i.e. a "null set")
;-
FUNCTION SetIntersection, intVectorA, intVectorB
minab = min(intVectorA, MAX=maxa) > min(intVectorB, MAX=maxb) ;Only need intersection of ranges
maxab = maxa 
; Finds members of set A that are not in set B
;
; @Param
;   intVectorA {in} {required} {type=vector of positive integers} 
;     A set of positive integers
;
; @Param
;   intVectorB {in} {required} {type=vector of positive integers} 
;     A set of positive integers
;
; @Author
;   IDL Founder David Stern
;
; @Examples
;   Run IDL> SET_MATH_OPERATOR_LIBRARY to demonstrate
;
; @History
;   Created August 29, 1997
;
; @Returns
;   A positive integer array of same datatype as highest-precedent input arg
;   *** OR *** scalar -1 if there is no difference between the two inputs.
;-
FUNCTION SetDifference, intVectorA, intVectorB  ; = a and (not b) = elements in A but not in B
mina = min(intVectorA, MAX=maxa)
minb = min(intVectorB, MAX=maxb)
if (minb gt maxa) or (maxb lt mina) then return, intVectorA ;No intersection...
r = where((histogram(intVectorA, MIN=mina, MAX=maxa) ne 0) and $
          (histogram(intVectorB, MIN=mina, MAX=maxa) eq 0), count)
if count eq 0 then return, -1 else return, r + mina
end
;+
; 
; A simple test driver to demonstrate David Stern's three set operator
; functions
;
; @Author
;   James Jones (jjayjones\@comcast.net)
;
; @History
;   Created June 9, 2008
;-
PRO set_math_operator_library
intVectorA = [2,4,6,8]
intVectorB = [6,1,3,2]
print, intVectorA, FORMAT='("Set A = {", 4I3, "  }")'
print, intVectorB, FORMAT='("Set B = {", 4I3, "  }")' 
commonElements = SetIntersection(intVectorA, intVectorB)       ; [2,6]
print, commonElements, FORMAT='("Intersection of sets = {", ' + $
    strtrim(n_elements(commonElements), 2) + 'I3, "  }")'
nonredundantUnitedElements = SetUnion(intVectorA, intVectorB)  ; [1,2,3,4,6,8]
print, nonredundantUnitedElements, FORMAT='("Union of sets = {", ' + $
    strtrim(n_elements(nonredundantUnitedElements), 2) + 'I3, "  }" )'
uniqueInA = SetDifference(intVectorA, intVectorB)              ; [4, 8]
print, uniqueInA, FORMAT='("Elements in A but not in B = {", ' + $
    strtrim(n_elements(uniqueInA), 2) + 'I3, "  }" )'
print, 'Testing intersection of A with {  3  5  7  }'
print, SetIntersection(intVectorA,[3,5,7])      ; = -1, indicator for null set 
ENDJames Jones 
										
									 |