Advertisement
imjyb1008work

SQL GETDATE CONVERT

Nov 5th, 2015
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.82 KB | None | 0 0
  1. - Microsoft SQL Server T-SQL date and datetime formats
  2. - Date time formats - mssql datetime
  3. - MSSQL getdate returns current system date and time in standard internal format
  4. SELECT convert(varchar, getdate(), 100) - mon dd yyyy hh:mmAM (or PM)
  5.                                         - Oct  2 2008 11:01AM          
  6. SELECT convert(varchar, getdate(), 101) - mm/dd/yyyy - 10/02/2008                  
  7. SELECT convert(varchar, getdate(), 102) - yyyy.mm.dd - 2008.10.02          
  8. SELECT convert(varchar, getdate(), 103) - dd/mm/yyyy
  9. SELECT convert(varchar, getdate(), 104) - dd.mm.yyyy
  10. SELECT convert(varchar, getdate(), 105) - dd-mm-yyyy
  11. SELECT convert(varchar, getdate(), 106) - dd mon yyyy
  12. SELECT convert(varchar, getdate(), 107) - mon dd, yyyy
  13. SELECT convert(varchar, getdate(), 108) - hh:mm:ss
  14. SELECT convert(varchar, getdate(), 109) - mon dd yyyy hh:mm:ss:mmmAM (or PM)
  15.                                         - Oct  2 2008 11:02:44:013AM  
  16. SELECT convert(varchar, getdate(), 110) - mm-dd-yyyy
  17. SELECT convert(varchar, getdate(), 111) - yyyy/mm/dd
  18. SELECT convert(varchar, getdate(), 112) - yyyymmdd
  19. SELECT convert(varchar, getdate(), 113) - dd mon yyyy hh:mm:ss:mmm
  20.                                         - 02 Oct 2008 11:02:07:577    
  21. SELECT convert(varchar, getdate(), 114) - hh:mm:ss:mmm(24h)
  22. SELECT convert(varchar, getdate(), 120) - yyyy-mm-dd hh:mm:ss(24h)
  23. SELECT convert(varchar, getdate(), 121) - yyyy-mm-dd hh:mm:ss.mmm
  24. SELECT convert(varchar, getdate(), 126) - yyyy-mm-ddThh:mm:ss.mmm
  25.                                         - 2008-10-02T10:52:47.513
  26. - SQL create different date styles with t-sql string functions
  27. SELECT replace(convert(varchar, getdate(), 111), -/-, - -) - yyyy mm dd
  28. SELECT convert(varchar(7), getdate(), 126)                 - yyyy-mm
  29. SELECT right(convert(varchar, getdate(), 106), 8)          - mon yyyy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement