Link to home
Create AccountLog in
Avatar of robrodp
robrodpFlag for Mexico

asked on

ms sql and asp dates

I have a date field in my ms sql table (fecha). I really cant make any changes in the table.

in my asp code

I set fecha=RecordSet("fecha")

I get fecha a long date  with time like;

2017-05-04 12:58:17.0000000

I need to get: (day/month/year)

I am at a loss
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>I need to get: (day/month/year)
(Potentially stupid question) Doesn't .ASP have the ability to format dates?  SQL Server can do this formatting but it will return it as a varchar column and not a date column, which will impact any date math and sorting on the front-end.

SELECT convert(varchar, your_data_here ,1) 

Open in new window

in your select, use

cast(yourDateTimeColumn as Date) yourDateColumn

and use yourDateColumn in your code...
or use this in asp to format

FormatDateTime(yourDateTimeColumn ,"dd/mm/yyyy")
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of robrodp


Did th job