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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date from Calendar Control to input in to query as yyyy-mm-dd Format

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
I currently have a query that requires me to input a date. Because the query is attached to a table that has
the date as 2008-01-31 I need some help. I am trying to select the date from a Calendar 11 control and
the Calendar inputs the date as 1/31/2008. What I want is as follows:

I click a command button that opens up the Calendar Form. No problem there. I select the date from the Calendar
that is for a Query. No problem there. I need the date to input into the query as 2008-01-31 instead
of 1/31/08 from the Calendar. BIG PROBLEM THERE at least for me. Any advice on how to accompish this?
 
In your query, you can select all the columns you are now already selecting, but ADD an additional computer column that formats the date in a format that will match the calendar control's input. Ie, in your query, add ANOTHER column:

FormattedDate: format([DATECOLUMN],"mm/dd/yyyy")

If doing it by code, use "SELECT .... format([DATECOLUMN],"mm/dd/yyyy") AS FormattedDate...."

Then make your calendar control input link to the query on THAT field instead of the other one.

SELECT from qry WHERE FormattedDate = cCalendaraControlDate ..."

Conversely, you could format the calendar control's date the same way:

cCalendarDate = format(now(),"yyyy-mm-dd")

and use that to link to the query column.


Geex, that rambled. I'm sorry. But I hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top