Erhard RAINER
  • Home
  • IT
    • Betriebssysteme
      • Windows
        • Hyper-V
        • Storage Pools
    • Business Intelligence
      • SQL Server Integration Service (SSIS)
      • PowerBI
    • BIG DATA – DATA SCIENCE
    • Datenbanken
      • Microsoft T-SQL
      • PostGreSQL
      • MongoDB
      • Apache Cassandra
    • Office
      • Excel
        • Excel-VBA
      • Access
      • Outlook
      • VBA
    • Scripting Sprache
      • powershell
    • Virtualisierung
    • Hardware
  • Recht
  • Wirtschaft
    • CRYPTOCURRENCIES
  • Search
    • All Downloads
    • List of All Posts
  • About
  • Contact
  • Impressum
Erhard RAINER
  • Home
  • IT
    • Betriebssysteme
      • Windows
        • Hyper-V
        • Storage Pools
    • Business Intelligence
      • SQL Server Integration Service (SSIS)
      • PowerBI
    • BIG DATA – DATA SCIENCE
    • Datenbanken
      • Microsoft T-SQL
      • PostGreSQL
      • MongoDB
      • Apache Cassandra
    • Office
      • Excel
        • Excel-VBA
      • Access
      • Outlook
      • VBA
    • Scripting Sprache
      • powershell
    • Virtualisierung
    • Hardware
  • Recht
  • Wirtschaft
    • CRYPTOCURRENCIES
  • Search
    • All Downloads
    • List of All Posts
  • About
  • Contact
  • Impressum
Erhard RAINER
  • Home
  • IT
    • Betriebssysteme
      • Windows
        • Hyper-V
        • Storage Pools
    • Business Intelligence
      • SQL Server Integration Service (SSIS)
      • PowerBI
    • BIG DATA – DATA SCIENCE
    • Datenbanken
      • Microsoft T-SQL
      • PostGreSQL
      • MongoDB
      • Apache Cassandra
    • Office
      • Excel
        • Excel-VBA
      • Access
      • Outlook
      • VBA
    • Scripting Sprache
      • powershell
    • Virtualisierung
    • Hardware
  • Recht
  • Wirtschaft
    • CRYPTOCURRENCIES
  • Search
    • All Downloads
    • List of All Posts
  • About
  • Contact
  • Impressum

DATE CONVERSIONS

STRING 2 DATE

SourceFormatExample
yyyy.mm.ddSELECT convert(datetime, ‘2021.03.30’, 102)
dd.mm.yyyySELECT convert(datetime, ‘30.03.2021’, 104)
dd/mm/yyyySELECT convert(datetime, ’30/03/2021′, 103)
yyyy-mm-ddSELECT convert(datetime, ‘2016-10-28’, 126)

further Information:

  • CAST and CONVERT (Transact-SQL)
  • Edgewood Solutions – Date and Time Conversions Using SQL Server
  • Rajendra Gupta – SQL Convert Date functions and formats

DATE 2 STRING

TargetFormatExample
dd.mm.yyyy
dd/mm/yyyy
yyyy-mm-dd
yyyymmddSelect Convert(CHAR(8),<date>,112)
Select cast(Convert(CHAR(8),<date>,112) as int)

A very important usecase – especially for creating Cubes – is converting a date to yyyymmdd (int)

further informaiton:

  • https://www.mssqltips.com/sqlservertip/6452/sql-convert-date-to-yyyymmdd/

About Me

about-me-image

related Posts

Gruppenbesteuerung

Gruppenbesteuerung

Join Us Today


2022 © All rights reserved
Don't have an account yet? Register Now