Question : TSQL what is the cleanest way to generate a date format of YYYYMMDD

I am trying to return the value of date inputted as mm-dd-yyyy to an ouput of yyymmdd in  SQL

Here is the function:

Alter function dbo.fn_get_YYYYMMDD

(@FN_date   int)

declare @result    int

set @result  =
       case When @Fn_date <> 01-01-1900  then
      convert (varchar,@FN_date, 1111)
         else 0
  end

Return @Result

End

-----------------------------------------------------------------------------------------------------------------

here is the test
select dbo.FN_Get_YYYYMMDD(08-18-1998)

This is the returned data :  (- 2008) which of course is wrong

Answer : TSQL what is the cleanest way to generate a date format of YYYYMMDD

I don't know the "technical" aspect of it, but I can tell you in a nutshell what I have experienced. We deal primarily with Sharp MFP from the tabletop machines all the way up to the 105 copies per minute. I have had several issues with different models where it would be asking for toner, some maintenance message that is only shown to technicians when they input service codes at the display pad, add paper, paper jam etc. etc. etc. When SNMP has been checked, it detects this message and halts printing. Sometimes it will effect one user and sometimes it effects multiple users. Sometimes resetting the machine will allow them to print, other times it requires a tech to visit the site to fix the issue. (Sharps way of fixing it was a firmware update to the machine along with updating the driver where SNMP is unchecked) In every instance, if the user walks up to make a copy it works fine. It only effects printing.
Random Solutions  
 
programming4us programming4us