Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

suppressing time when exporting dates to textfile (csv) 3

Status
Not open for further replies.

uscitizen

Technical User
Jan 17, 2003
672
US
i need to have dates expressed as YYYYMMDD in my export (csv) file. i created a test mdb and defined a date/time field with input mask 99/99/99 and format YYYYMMDD. when exporting the test values to the csv file, i find that my date (in this case 20040309 -- which is being displayed as such in the a2k table) is getting exported as 20040309 00:00. i don't want the time in the output file. what more do i need do? anybody know?

“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
that's the achilees' heel -- or why automation has feet of clay. technically nothing except their circumspection -- to minimize (but not altogether prohibit) the eventuality you raise i have used input mask and formats: 0000/00/00. not perfect i grant you, but it will have to do fttb.

“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
Hi

You could use CDate() to convert the entered data to a date (in memory) and trap any ensuing error with on error goto, and use this mechansim to verify your users are entering dates......

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
hi,

your suggestion looked good so i proceeded to hunt up some more about it in vba's reference documentation online. i turned up nothing helpful.

if you could, could you be a bit more specific.

you already know i'm currently inputting my date as a number (longinteger) using YYYYMMDD entry style.

what i think you're saying is that somehow CDate() could be brought to bear on the entered numbers provide feedback as to whether they were convertible into calendar values.



“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
Hi

That is it basically, I have not tried this, so it is not tested code, but something like

On Error GoTo ABC
If CDate(str(MyLongInt)) Then
EndIf
..etc

ABC:
MsgBox "Invalid Date"
MyLongInt.SetFocus
Cancel = True

in the Before Update event of the textbox control for your long int

there is also an IsDAte() function:

Returns a Boolean value indicating whether an expression can be converted to a date.

Syntax

IsDate(expression)

The required expression argument is a Variant containing a date expression or string expression recognizable as a date or time.

Remarks

IsDate returns True if the expression is a date or can be converted to a valid date; otherwise, it returns False. In Microsoft Windows, the range of valid dates is January 1, 100 A.D. through December 31, 9999 A.D.; the ranges vary among operating systems.

which may help you




Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
hi, anyone reading this thread may want to x-reference this one with thread701-788074.

i would be interested in learning which event should handle the testing process though.

“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top