Sybase: How to get the current date in mm/dd/yyyy format?
28,769
You are looking for this SQL to make the conversion:
select convert(varchar, date_column, 101) from the_table
The important part in part in this case is 101
which is specification of mm/dd/yyyy
format as per documentation. If you have Sybase ASE 15.7 use this, if you have SAP ASE 16.0 (released 2014) use this (has more options).
Author by
swateek
Foodie | Traveller | Technologist | blogs | lazy reader | Dog Lover | Wants to pet a baby elephant |
Updated on July 09, 2022Comments
-
swateek almost 2 years
I want to insert the mm/dd/yyyy format into a table and after that compare it with the current date when fetching results from the table to display.
The getdate() function returns the complete timestamp and am unable to extract the date in my desired format.
-
swateek almost 11 yearsNo @Rahul am looking for something like this UPDATE #sse_template_audit SET cre_date = getdate() WHERE cre_date= NULL I want to enter the date to that column in mm/dd/yyyy format only.
-
Rahul Tripathi almost 11 years@Swat:- Did you tried this:- UPDATE #sse_template_audit SET cre_date = convert(varchar, getdate(), 101) WHERE cre_date= NULL Although not very sure if that works!!
-
swateek almost 11 yearsCan you tell me why is that 101 used for? Am a bit confused about that.
-
Rahul Tripathi almost 11 years101 is for mm/dd/yyyy format. Check this out:- infocenter.sybase.com/help/index.jsp?topic=/…