Isdate, checking Formatting too e.g. dd/mm/yyyy

R

Rob W

Greetings,

I've used the IsDate successfully to check if a date within a text box is
valid.

When you enter the textbox the date is set to todays date and formatted
dd/mm/yyyy
txtDateAdmitted.Value = Format(Now, "dd/mm/yyyy")

However I would like to be flexiable and allow the user to enter date in any
format and then later apply the formatting of 'dd/mm/yyyy'
So far I have done this aslong as ISdate(textbox1.value) returns TRUE.

However to be more efficent how do I check the ISDate and the format is
dd/mm/yyyy ??

I've tried below but its syntically incorrect.

ElseIf IsDate(txtDateAdmitted.Value) And Not Format(txtDateAdmitted.Value,
"dd/mm/yyyy") Then


Cheers
Rob W
 
D

Dave Peterson

For the most part, I don't think you can.

How will your program ever decide what I meant when I typed:

01/02/2007

Should it be processed as January 2, 2007 or should your code treat it as
February 1, 2007?

You may want to drop the textbox and use an unambiguous way of getting the date.

Ron de Bruin shares calendar control instructions here:
http://www.rondebruin.nl/calendar.htm
 
S

Sunit Pulikottil

try this function:
=if(iserror(date(0,1,1)-Y5),"NotDate","date")

Y5 is the cell address
y5 should be in dateformat
you may use 0 and 1 instead "notdat","date"





Rob W wrote:

Isdate, checking Formatting too e.g. dd/mm/yyyy
06-Dec-07

Greetings

I've used the IsDate successfully to check if a date within a text box is
valid

When you enter the textbox the date is set to todays date and formatted
dd/mm/yyy
txtDateAdmitted.Value = Format(Now, "dd/mm/yyyy"

However I would like to be flexiable and allow the user to enter date in any
format and then later apply the formatting of 'dd/mm/yyyy
So far I have done this aslong as ISdate(textbox1.value) returns TRUE

However to be more efficent how do I check the ISDate and the format is
dd/mm/yyyy ?

I've tried below but its syntically incorrect

ElseIf IsDate(txtDateAdmitted.Value) And Not Format(txtDateAdmitted.Value,
"dd/mm/yyyy") The

Cheer
Rob W

Previous Posts In This Thread:

Isdate, checking Formatting too e.g. dd/mm/yyyy
Greetings

I've used the IsDate successfully to check if a date within a text box is
valid

When you enter the textbox the date is set to todays date and formatted
dd/mm/yyy
txtDateAdmitted.Value = Format(Now, "dd/mm/yyyy"

However I would like to be flexiable and allow the user to enter date in any
format and then later apply the formatting of 'dd/mm/yyyy
So far I have done this aslong as ISdate(textbox1.value) returns TRUE

However to be more efficent how do I check the ISDate and the format is
dd/mm/yyyy ?

I've tried below but its syntically incorrect

ElseIf IsDate(txtDateAdmitted.Value) And Not Format(txtDateAdmitted.Value,
"dd/mm/yyyy") The

Cheer
Rob W

For the most part, I don't think you can.
For the most part, I don't think you can

How will your program ever decide what I meant when I typed

01/02/200

Should it be processed as January 2, 2007 or should your code treat it a
February 1, 2007

You may want to drop the textbox and use an unambiguous way of getting the date

Ron de Bruin shares calendar control instructions here
http://www.rondebruin.nl/calendar.ht

Rob W wrote

--

Dave Peterson

EggHeadCafe - Software Developer Portal of Choice
Use Assembly Helper Class to retrieve Information on any assembly
http://www.eggheadcafe.com/tutorial...a-e463a6ec1436/use-assembly-helper-class.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top