View Full Version : Re help me about date formating


sachinInPune
09-29-2006, 12:53 AM
hello

i am using a 2 tables where in one table my startdate format is general.
where as in another table date format is shortdate

now i want to compare 2 dates in select query

my query is

rsBreakDown.Open "select Breakdown.*,EquipmentMaster.McName from BreakDown inner join EquipmentMaster on reakdown.McNo=EquipmentMaster.McNo where startdate <=#" & dtpshow.value", conn, adOpenKeyset, adLockOptimistic

here startdate is in general format n dtpshow is in shortdate format

i want to compare these 2 dates

how can i?
is anybody help me?

macca the hacke
09-29-2006, 03:17 AM
IIf(Format([startdate],"Short Date")=[dtpshow],"same","different")

Jon K
09-29-2006, 07:07 AM
You need to use a pair of # signs to delimit the date value.
You can extract the date values from general startdate by using the DateValue() function.
And if dtpshow is a control on the form, you can use Me.dtpshow. That is,

rsBreakDown.Open "select Breakdown.*,EquipmentMaster.McName from BreakDown inner join EquipmentMaster on Breakdown.McNo=EquipmentMaster.McNo where DateValue(startdate) <=#" & Me.dtpshow & "#", conn, adOpenKeyset, adLockOptimistic


In VBA code, the # sign works properly only on systems using the US date format. If your system uses another date format, you need to format the date value to a US date. That is,

rsBreakDown.Open "select Breakdown.*,EquipmentMaster.McName from BreakDown inner join EquipmentMaster on Breakdown.McNo=EquipmentMaster.McNo where DateValue(startdate) <=#" & Format(Me.dtpshow, "m/d/yyyy") & "#", conn, adOpenKeyset, adLockOptimistic

.