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

convert DateTime to mm/dd/yyyy format

Status
Not open for further replies.

royyan

Programmer
Jul 18, 2001
148
US
I need suggestions to convert DateTime to mm/dd/yyyy format in a SQL statement. Can anybody help me? Thanks!
 
The SQL Statement is in ASP/VB or in a stored procedure?
If is the first case then use the function

FormatDateTime(Date(),2)
 
if it is in SQL then use the following in the SQL string
"convert(datetime," & the variable for date time & " )"
 
After using "convert" in my SQL atatement, the ASP page shows following errors:

*****************************************
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Undefined function 'convert' in expression.
*****************************************
Do you have any idea what happened here?

For your reference, here is my code:

"select count(*) as TotalCount, convert(datetime, Date) as Date1 from MyTable where Date between #" & fromDate & "# and #" & toDate & "# group by convert(datetime, Date)"


Thanks a lot!
 
I work more with SQL server and that function is supported. It may not be supported in Access.
 
I think that is the problem. I checked Jet-SQL, there is no "convert" function. I will try other ways to get this work done. If you guys come up new solution, please let me know also.
Thanks for all the information!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top