Avatar of robrodp
robrodp
Flag 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
ASPMicrosoft SQL Server

Avatar of undefined
Last Comment
robrodp

8/22/2022 - Mon
Jim Horn

>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

HainKurt

in your select, use

cast(yourDateTimeColumn as Date) yourDateColumn

and use yourDateColumn in your code...
HainKurt

or use this in asp to format

FormatDateTime(yourDateTimeColumn ,"dd/mm/yyyy")
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Big Monty

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
robrodp

ASKER
Did th job