Wednesday, March 21, 2012

Date manipulation

I need to to get the result of the function GETDATE and converted to a simpler "mm/dd/yyyy" format in order to compare the results to another date in a table. In ACCESS the function DATE returns the format of 'mm/dd/yyyy' since I need to work with date ranges without a need for this application 'HH:MM:SS'

I have try 'TRANSFORM(GETDATE,'mm/dd/yyyy') but I keep getting errors.

I am not sure what I am doing wrong? Any help is appreciated since I need to work in SQL Server 2000.

Gratefull

Neil

If you want to store the "tranformed date" in a datetime column, the hh,mm,ss will still be added to the column, although they might be NULL, depending on your operation you use for the transform, but if you want to simply minsert the transformed/converted date into a character column you can do the following:

SELECT CONVERT(VARCHAR(10),GETDATE(),1)

See the CONVERT function in the BOL for more information.

HTH, Jens SUessmeyer.


http://www.sqlserver2005.de

|||Thanks for your help Jens, I am still making the transition from ACCESS Functions to SQL Server and how to get similar results

No comments:

Post a Comment