Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Date comparison

 
   Database Help (Home) -> Visual Basic RSS
Next:  SQLite on VB6  
Author Message
AndyG

External


Since: Jun 09, 2004
Posts: 1



(Msg. 1) Posted: Wed Jun 09, 2004 7:08 pm
Post subject: Date comparison
Archived from groups: microsoft>public>vb>database (more info?)

Could someone please tell me how to do a date comparison. I have
txtCheckDate (a text box), and cmdCheckDate (a command button). I would like
the user to enter a date in mm/dd/ccyy format, and then I would like to see
if the date entered is either => the current system date

something like

if txtCheckDate < Now then
msgbox "Date entered is in the past", , "Check Date"
end if

I get all sorts of errors, perhaps the data types are wrong. I can get it to
work by loading variables with mm, dd, ccyy for both current date (byte
addressing the Now), and also the entered check date, multiplying them by 1
and using them as integers. However that is bad coding. There must be a
simple way to do this. Please help

Thanks in advance
God bless you

 >> Stay informed about: Date comparison 
Back to top
Login to vote
Victor Koch2

External


Since: Dec 04, 2003
Posts: 22



(Msg. 2) Posted: Wed Jun 09, 2004 8:32 pm
Post subject: Re: Date comparison [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Andy,

if cdate(txtCheckDate) < date then
msgbox "Date entered is in the past", , "Check Date"
end if

--
Víctor Koch From Argentina.


"AndyG" escribió en el mensaje
news:#ByC$1lTEHA.1244@TK2MSFTNGP10.phx.gbl...
 > Could someone please tell me how to do a date comparison. I have
 > txtCheckDate (a text box), and cmdCheckDate (a command button). I would
like
 > the user to enter a date in mm/dd/ccyy format, and then I would like to
see
 > if the date entered is either => the current system date
 >
 > something like
 >
 > if txtCheckDate < Now then
 > msgbox "Date entered is in the past", , "Check Date"
 > end if
 >
 > I get all sorts of errors, perhaps the data types are wrong. I can get it
to
 > work by loading variables with mm, dd, ccyy for both current date (byte
 > addressing the Now), and also the entered check date, multiplying them by
1
 > and using them as integers. However that is bad coding. There must be a
 > simple way to do this. Please help
 >
 > Thanks in advance
 > God bless you
 >
 >

 >> Stay informed about: Date comparison 
Back to top
Login to vote
Jezebel2

External


Since: Apr 20, 2004
Posts: 21



(Msg. 3) Posted: Thu Jun 10, 2004 11:15 am
Post subject: Re: Date comparison [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

You're actually doing two distinct things. First, you need to check that the
user has entered a real date. You should not be forcing the user to adopt
the US (or any) date convention; you should respect their regional settings.
None of the date conversion functions like CDate() or DateValue() is
bulletproof, but they work reasonably well for most purposes most of the
time. Convert the user string to a date variable, and deal with any error
that arises if the string is invalid. (If you need bulletproof, use a
DatePicker or similar control that is guaranteed to return a date.)

Then make your comparison. Since dates are actually numbers, simple
comparison works fine.


"AndyG" wrote in message

 > Could someone please tell me how to do a date comparison. I have
 > txtCheckDate (a text box), and cmdCheckDate (a command button). I would
like
 > the user to enter a date in mm/dd/ccyy format, and then I would like to
see
 > if the date entered is either => the current system date
 >
 > something like
 >
 > if txtCheckDate < Now then
 > msgbox "Date entered is in the past", , "Check Date"
 > end if
 >
 > I get all sorts of errors, perhaps the data types are wrong. I can get it
to
 > work by loading variables with mm, dd, ccyy for both current date (byte
 > addressing the Now), and also the entered check date, multiplying them by
1
 > and using them as integers. However that is bad coding. There must be a
 > simple way to do this. Please help
 >
 > Thanks in advance
 > God bless you
 >
 >
 >> Stay informed about: Date comparison 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
sql query returns in wrong format - Hi, Hope someone can help me with this. I have MS SQL 2000 database where i have Table "PriceList" and there a column "Pricemk" wich is data type "money". All data in this column is in form "10001,35". So why when...

arrays - is there a way to concatenate the contents of an array (looping through the array) and storing each item in a comma delimited string? Thanks!

DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a datareport for example after 5 records printed. Thank you all

Possible Use of a Cursor - I have a complex query that I hope I can explain it well enough for everyone to understand. I have a table that contains information for work instructions. Contained in the table are "MACHINE_PROC" these are groupings of machining processes....

Scroll Bars - Is there a way to find the size of scrollbars on a system using Visual Basic 6.0? I know how to look and change them on the display properties, but I don't know how to access that information from within Visual Basic.
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]