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

Concatenate Dates in SQL

Status
Not open for further replies.

darude

Programmer
Jun 23, 2003
138
US
Good morning!!

I am populating a combo box with the year based on the user selecting Summer or School Year from another combo box. Summer I'm all set with, but I want the School Year to look like 2008-2009 or 2007-2008 so I need to concatenate the year of the start date with the year of the end date. I'm getting an empty combo box, no errors. Here is my SQL statement. Thank you for any help you can provide.

strSQL = "SELECT Year([startdate])+ '-' +Year([enddate]) AS [Year], RolloverPeriods.Description FROM RolloverPeriods WHERE (((RolloverPeriods.Description)='sy1'));"

Me.cboYear.RowSource = strSQL
 
Does this query return anything

SELECT Year([startdate])+ '-' +Year([enddate]) AS [Year], RolloverPeriods.Description FROM RolloverPeriods
 
how about this

SELECT Year([startdate]),Year([enddate]) AS [Year], RolloverPeriods.Description FROM RolloverPeriods
 
Hi,

"the year based on the user selecting Summer or School Year from another combo box."

Where is the VALUE from "another combo box" and the field your are using for this criteria value in your WHERE clause???

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
What about this ?
SELECT Year([startdate]) [!]&[/!] '-' [!]&[/!] Year([enddate]) AS [Year]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
There is a table that contains dates that coincide with a school year. The the Start Date is 9/1/2007 and the End date is 1/31/2008. I need it to look like 2007-2008 in the combo box for user selection.

pwise - that did work, but it looks like
2005
2005
2005
2006
2006
2006 etc.

 
Can you provide some sample data

Select top 5 * from RolloverPeriods
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top