Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Working with a date string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charlie - 30 Jan 2006 05:53 GMT
I was going to use an input box to ask the user for a date but I'm not sure
the type of object it should be. I don't want it as a String because I need
to use the date in this way to export it as a calendar event. In the InputBox
default I could put something like "1/27/06" and have the message to prompt
them to follow this format, but that wouldn't be an integer then.  I also
need to calculate another date from their input, like 3 days after the day
that they input, so a String wouldn't work either would it?
Stumped,
Charlie
Jezebel - 30 Jan 2006 13:03 GMT
Read Help on the date functions. The best data entry method is to use one of
the date controls like DatePicker or Calendar, which is guaranteed to return
a valid date; next best is to let the user enter the date as a string then
use CDate() or DateValue() to convert it then display the converted value
back to the user. The conversions in both directions should use the user's
own regional settings rather than assuming m/dd/yy (as you seem inclined to
do -- *most* of the world does not use that format).

To calculate another date from a given date you can use the DateAdd()
function; or if you are dealing with simple day offsets you can just
add/subtract. (And forget about integers. Internally, dates are doubles.)

>I was going to use an input box to ask the user for a date but I'm not sure
> the type of object it should be. I don't want it as a String because I
[quoted text clipped - 8 lines]
> Stumped,
> Charlie
Kevin B - 30 Jan 2006 13:43 GMT
I you go the Input Box route, in addition to the aforementioned formula
functions (CDate(), DateValue())  you can use the IsDate() function to
determine if the entry can be read as a vaild date.
Signature

Kevin Backmann

> Read Help on the date functions. The best data entry method is to use one of
> the date controls like DatePicker or Calendar, which is guaranteed to return
[quoted text clipped - 20 lines]
> > Stumped,
> > Charlie
Jezebel - 30 Jan 2006 21:00 GMT
IsDate() has a rather poor reputation. The function returns true for times
as well as dates, so it accepts entries like "23:59:59" and "1.1.1" -- on
the other hand it rejects legitimate foreign language dates like "4 Enero
2006".

>I you go the Input Box route, in addition to the aforementioned formula
> functions (CDate(), DateValue())  you can use the IsDate() function to
[quoted text clipped - 32 lines]
>> > Stumped,
>> > Charlie

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.