|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
compare value from DTPicker and now()When i do the immediate enquiry:
Format(Now(), "YYYY/M/D") = 2005/7/7 dtpShipDate.Value = 2005/7/7 When I do the following comparison, the value is always false: Format(Now(), "YYYY/M/D") = dtpShipDate.Value Anybody knows why? "Henry" <henry@office> wrote in message news:O$3zC2tgFHA.3656@TK2MSFTNGP09.phx.gbl... You are trying to compare a string to a Date data type, which is stored internally as a double. VB is using Evil Type Conversion> When i do the immediate enquiry: > Format(Now(), "YYYY/M/D") = 2005/7/7 > dtpShipDate.Value = 2005/7/7 > > When I do the following comparison, the value is always false: > Format(Now(), "YYYY/M/D") = dtpShipDate.Value > > Anybody knows why? > > (ETC) to try to figure out what you really want. If you format the dtpShipDate.Value using the same format string as you did for Now(), everything will work. That is: Format(Now(), "YYYY/M/D") = Format(dtpShipDate.Value, "YYYY/M/D") Will return True, at least today. -- Al Reid
Show quote
Hide quote
"Al Reid" <arei***@reidDASHhome.com> wrote in message Or better yet, use the DateDiff function.news:udxN2eugFHA.1868@TK2MSFTNGP10.phx.gbl... > "Henry" <henry@office> wrote in message > news:O$3zC2tgFHA.3656@TK2MSFTNGP09.phx.gbl... >> When i do the immediate enquiry: >> Format(Now(), "YYYY/M/D") = 2005/7/7 >> dtpShipDate.Value = 2005/7/7 >> >> When I do the following comparison, the value is always false: >> Format(Now(), "YYYY/M/D") = dtpShipDate.Value >> >> Anybody knows why? >> >> > > You are trying to compare a string to a Date data type, which is stored > internally as a double. VB is using Evil Type Conversion > (ETC) to try to figure out what you really want. If you format the > dtpShipDate.Value using the same format string as you did for > Now(), everything will work. That is: > > Format(Now(), "YYYY/M/D") = Format(dtpShipDate.Value, "YYYY/M/D") > > Will return True, at least today. -- Mike Microsoft MVP Visual Basic Try this:
if Date = dtpShipDate.Value then Of course, if you only want to compare dates and not times, leave the datetime picker's default format (ie it only accepts dates) as is. Good luck! Saga .. Show quoteHide quote "Henry" <henry@office> wrote in message news:O$3zC2tgFHA.3656@TK2MSFTNGP09.phx.gbl... > When i do the immediate enquiry: > Format(Now(), "YYYY/M/D") = 2005/7/7 > dtpShipDate.Value = 2005/7/7 > > When I do the following comparison, the value is always false: > Format(Now(), "YYYY/M/D") = dtpShipDate.Value > > Anybody knows why? > |
|||||||||||||||||||||||