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!

Formatting date VB/SQL into list box 1

Status
Not open for further replies.

Egglar

Technical User
Apr 4, 2002
88
GB
Hello.

I have a set of records in tblPurchaseInvoice

I want to fill a list box on a form with dates that are in this table, and change the format, eg..

tblPurchaseInvoice.Date
01/01/03
01/01/03
02/01/03
05/01/03
01/02/03
01/02/03
04/03/03
04/03/03
01/06/03
01/03/03

Listbox displays:
January 2003
Febuary 2003
March 2003
June 2003

I would rather do this by the row source property of the list box with sql, but i dont mind doing it through VB.

Thanks for your help in advance, Elliot.

 
in SQL you have something like
Code:
"SELECT myDateField from MYTABLENAME"

Switch this to:
Code:
SELECT Format([myDateField],"mmmm yyyy") as FormattedDate from MYTABLENAME


Note that the quotes around "mmmm yyyy" may disappear if you actually paste this into the SQL box - just double-check that.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
Byah, let's try this again:

Code:
SELECT Format([myDateField],"mmmm yyyy") as FormattedDate from MYTABLENAME GROUP BY FormattedDate


If that errors, then you have to do the weird GROUP BY-calculated-value-workaround:

Code:
SELECT Format([myDateField],"mmmm yyyy") as FormattedDate from MYTABLENAME GROUP BY Format([myDateField],"mmmm yyyy")


--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
I was so close with the formatting! i had Test:Format([Date],yyyy mmmm)


Thanks!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top